Environment.MachineName 是否有可能返回零长度字符串
我正在客户站点上追踪一个奇怪的错误,并且想知道 Environment.MachineName
是否可能返回零长度字符串。文档说这是从注册表中读取的,但没有指定在哪里。我无法想象一台机器不能有 netbios 名称,但我只是想问一下。
编辑
经过一番调查,似乎这没有返回零长度字符串,但我只是感兴趣是否可行。
I am chasing a strange error at a customer site and was wondering if it is possible that Environment.MachineName
could return a zero length string. The docs say this is read from the registry but doesn't specify where. I can't imagine that a machine cannot have a netbios name but just wanted to ask.
EDIT
After some investigation, it appears that this was not returning a zero length string, but I was just interested if it is feasible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道它是否可以是空字符串,抱歉,但是关于注册表,您可能需要检查以下内容(和子项):
在我的系统上,它实际上正在查看
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ ComputerName\ActiveComputerName\ComputerName
:顺便说一句,正如你所看到的,我尝试使用 SysInternals Process Monitor 来解决这个问题,但最初失败了。然后我想,默认情况下会抑制上述键(以及一些相关的键)。以防万一你尝试同样的做法,请注意这一点。
您还可以检查
%COMPUTERNAME%
的值。尽管我没有参考或直接证据,但我认为它的价值来自同一来源。我知道这不是您问题的真正答案,但它也不适合评论。
I don't know if it can be an empty string, sorry, but concerning the registry you might want to check the following (and subkeys):
On my system it is actually looking at
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName
:BTW, as you can see I tried to figure this out using SysInternals Process Monitor, but initially failed. Then i figured, that the above keys (and some related ones) are suppressed by default. Just in case you try the same be aware of that.
You might also check the value of the
%COMPUTERNAME%
. Although I have no reference or direct evidence, I would assume that it gets its value from the same source.I know this is not a real answer to your question, but it wouldn't fit in a comment either.