注册表键方法'GetValue()'返回NULL,即使该键存在。

编程入门 行业动态 更新时间:2024-10-18 18:24:39
本文介绍了注册表键方法'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,即使该键存在。

本文发布于:2023-11-06 14:06:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563899.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:注册表   使该   方法   GetValue   NULL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!