Windows 服务(密钥)名称中的有效字符是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/801280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:22:23  来源:igfitidea点击:

What are valid characters in a Windows service (key) name?

windowswindows-services

提问by miki

Does anyone happen to know what the convention for Windows service key names is, which characters are legal?

有没有人知道 Windows 服务密钥名称的约定是什么,哪些字符是合法的?

采纳答案by Richard Szalay

Based on the documentationfor the underlying C++ structure used to create a service:

基于用于创建服务的底层 C++ 结构的文档

The maximum string length is 256 characters. The service control manager database preserves the case of the characters, but service name comparisons are always case insensitive. Forward-slash (/) and backslash (\) are not valid service name characters.

最大字符串长度为 256 个字符。服务控制管理器数据库保留字符的大小写,但服务名称比较始终不区分大小写。正斜杠 (/) 和反斜杠 (\) 不是有效的服务名称字符。

Additionally, the following rules apply to the "Display Name":

此外,以下规则适用于“显示名称”:

This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. Display name comparisons are always case-insensitive.

此字符串的最大长度为 256 个字符。该名称在服务控制管理器中保留大小写。显示名称比较始终不区分大小写。

回答by Timo Sperisen

Additional Information to the Response from Richard Szalay.

Richard Szalay 回复的附加信息。

According to ServiceInstaller.ServiceName on MSDN

根据MSDN上的ServiceInstaller.ServiceName

The ServiceName cannot be null or have zero length. ... It also cannot contain ... characters from the ASCII character set with value less than decimal value 32.

ServiceName 不能为空或长度为零。... 它也不能包含 ... ASCII 字符集中的字符,其值小于十进制值 32。