问题从注册表取值 [英] Issue with fetching value from registry
问题描述
你好我是从注册表中显示的版本价值。对于从注册表中读取值,我做了以下code。
Hi i am displaying version value from registry .For fetching value from registry i did the following code.
// Where WrmSpoAgentRoot= @"Software\syscon\Point Monitor\";
string keySpoPath = SpoRegistry.WrmSpoAgentRoot;
RegistryKey regkey = Registry.LocalMachine.OpenSubKey(keySpoPath);
但我想在一个property..So我创建了一个属性Wrmversion分配该值。但是,当我分配这个值,,'REGKEY'变量没有分配到 该属性意味着智能感知是不生产REGKEY'变量(名称'REGKEY在目前的情况下不存在)
But i want to assign this value in to a property..So i created a property "Wrmversion".But when i am assigning this value ,,'regkey' variable is not assigning in to the property means intellisense is not producing 'regkey' variable(The name 'regkey' does not exist in the current context)
public string Wrmversion
{
get { return m_wrmversion; }
set { m_wrmversion = value; }
}
private string m_wrmversion = string)regkey.GetValue(
SpoRegistry.regValue_CurrentVersion);
有没有办法在财产分配值如
Is there any way to assign value in to property like
推荐答案
写此分配中的构造函数中。
Write this assignment inside a constructor.
让我们假设这个类名为foobar的。你应该写:
Let's suppose this class is named FooBar. You should write:
class FooBar
{
//other code goes here
public FooBar()
{
m_wrmversion = (string)regkey.GetValue(SpoRegistry.regValue_CurrentVersion);
}
}
这篇关于问题从注册表取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!