我有一个Windows服务,它有几个故障条件阻止它启动,每个都有唯一的退出代码。我想知道是否有一种方法可以向用户显示一些有用的东西。
作为测试,我有一个服务:
internal class MyServiceName : ServiceBase
{
protected override void OnStart(string[] startArgs)
{
// always fail, for demo purposes
ExitCode = 164;
Stop();
}
}
开始的时候,因为
164
standard System Error Code
,Windows显示相应的内置消息:
如果我使用的代码不是Windows使用的,比如
0x8744
(
34628
),我得到一个显示整数和十六进制值的一般错误消息:
net start myservicename
它显示了以下内容:
The MyServiceName service is starting.
The MyServiceName service could not be started.
A system error has occurred.
System error 34628 has occurred.
The system cannot find message text for message number 0x8744 in the message file for BASE.
-
有没有办法为这个服务提供一个“消息文件”,这样我就可以设置有用的消息?
-
我可以覆盖“标准”代码(如164)的消息吗?
-