开发者

Is it possible that Environment.MachineName returns a zero length string

开发者 https://www.devze.com 2023-03-06 22:31 出处:网络
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

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.


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):

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName

On my system it is actually looking at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName:

Is it possible that Environment.MachineName returns a zero length string

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消