Chinaunix首页 | 论坛 | 博客
  • 博客访问: 746387
  • 博文数量: 128
  • 博客积分: 7079
  • 博客等级: 少将
  • 技术积分: 1326
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-16 08:53
文章分类

全部博文(128)

文章存档

2011年(3)

2010年(12)

2009年(9)

2008年(23)

2007年(61)

2006年(20)

我的朋友

分类: C/C++

2007-09-12 15:01:22

今天看了《用 C++ 创建简单的 Win32 服务程序》一文,里面提到了将服务的运行的状态写到日志里,这时就要自己生成一个消息表,将这些消息放到程序里,用ReportEvent就能将记录写到日志里,文章里给出了具体方法,但是其中有个步骤是:

用VC自带的MC.exe 编译一个*.mc文件,生成*.h,*.rc,*.bin
查了下资料后自己成功编译了一个.mc文件,具体操作如下:
 
1、创建.mc文件
  .mc的格式是这样的:
 
MessageId=100
SymbolicName=EVMSG_INSTALLED
Language=English
The %1 service was installed.
.
MessageId=
SymbolicName=EVMSG_REMOVED
Language=English
The %1 service was removed.
.
MessageId=
SymbolicName=EVMSG_NOTREMOVED
Language=English
The %1 service could not be removed.
.
MessageId=
SymbolicName=EVMSG_CTRLHANDLERNOTINSTALLED
Language=English
The control handler could not be installed.
.
MessageId=
SymbolicName=EVMSG_FAILEDINIT
Language=English
The initialization process failed.
.
MessageId=
SymbolicName=EVMSG_STARTED
Language=English
The service was started.
.
MessageId=
SymbolicName=EVMSG_BADREQUEST
Language=English
The service received an unsupported request.
.
MessageId=
SymbolicName=EVMSG_DEBUG
Language=English
Debug: %1
.
MessageId=
SymbolicName=EVMSG_STOPPED
Language=English
The service was stopped.
.
 
2 、了解mc.exe的命令
   先看下下面的描述:
Using MC (The MC Command Line)
The message compiler has the following command-line syntax.
MC [-v] [-w] [-s] [-d] [-h dir] [-e extension] [-r dir] filename[.mc]

-v
Generates verbose output to stderr.
-w
Generates a warning message whenever an insert escape sequence is seen that is a superset of the type supported by the OS/2 MKMSGF utility. These are any escape sequences other than %0 and %n. This option is useful for converting MKMSGF message files to MC format.
-s
Adds an extra line to the beginning of each message that is the symbolic name associated with the message identifier.
-d
Outputs Severity and Facility constants in decimal. Sets the initial output radix for messages to decimal.
-hdirs
Target directory of the generated include file. The include-file name is the base name of the .mc file with a .h extension.
-eextension
Extension for the header file, which can be from one to three characters. The default is .h.
-rdir
Target directory of the generated resource compiler script (.rc file). The script file name is the base name of the .mc file with a .rc extension.
filename[.MC]
Input message file that is compiled into one or more binary resource files, one for each language specified in the message file.
The message compiler reads the message file and generates a C/C++ include file containing definitions for the symbolic names. For each LanguageId statement, the message compiler generates a binary file containing a message table resource. It also generates a single resource script file that contains the appropriate resource compiler statements to include each binary output file as a resource with the appropriate symbolic name and language type.
 
最后根据这个说明我们知道应该用-v, -h,-r 这几个命令。
3、编译
 我的编译步骤 “开始”-“运行” - 'cmd',在命令行下输入mc -v -h c:\test -r c:\test c:\test\test.mc
前提是你在c:\test目录下有个编辑好的test.mc 文件,编译后到c:\test目录下看看,具体每个命令的含义应该就一目了然了。
 
 
阅读(4704) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~