本文介绍了注册表键方法'GetValue()'返回NULL,即使该键存在。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个方法可以返回Windows注册表项的值。它在一台机器的Windows服务中工作正常(Windows Server 2008 R2标准)。 请看下面的内容。
Hi, I have a method which returns the value of a windows registry key. It is working fine in a windows service in one machine (windows server 2008 R2 standard). Please have a look at below.
private string GetLastDate() { Microsoft.Win32.RegistryKey key; key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("EMPSWIPELASTDATE"); String RegLstDate = (String)key.GetValue("LASTDATE"); return RegLstDate; }问题: 问题是,当我在另一台Windows机器(相同的配置)中安装相同的服务时,服务正在运行,但它返回NULL。 请列出可能的原因。 谢谢,
issue: The issue is, when i install the same service in another windows machine (same configuration), service is running but it returns NULL. Kindly list the possible reasons. Thanks,
推荐答案该服务作为没有设置该注册表项的用户运行其他机器。 The service is running as a user that does not have that registry key set on the other machine.
更多推荐
注册表键方法'GetValue()'返回NULL,即使该键存在。
发布评论