VC自带的 mc.exe的使用

今天看了《用 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目录下看看,具体每个命令的含义应该就一目了然了。
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值