使用WMI读取注册表项 [英] Reading registry keys using WMI
问题描述
我正在尝试使用WMI读取注册表项。我尝试过以下代码,但我无法获得注册表项值。
任何人都可以帮我解决这个问题。
< pre lang =c#> ConnectionOptions oConn = new ConnectionOptions();
System.Management.ManagementScope scope = new System.Management.ManagementScope( @ \\ + hostname + @ \ root \\ \\ cimv2,oConn);
scope.Connect();
ManagementClass registry = new ManagementClass(范围, new ManagementPath( StdRegProv), null );
ManagementBaseObject inParams = registry.GetMethodParameters( GetStringValue);
inParams [ sSubKeyName] = HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\\\ NETFramework;
inParams [ sValueName] = InstallRoot;
ManagementBaseObject outParams = registry.InvokeMethod( GetStringValue ,inParams, null );
if (outParams.Properties [ sValue]。值!= null )
{
output = outParams.Properties [ sValue]。Value.ToString();
}
注意:我想通过仅使用WMI读取注册表项
您好,
我认为以下网址对您有所帮助。
http:/ /social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/30db8534-0a15-4ba7-9b55-7ab772633d68 [ ^ ]
谢谢,
Suneel Kumar SVS。
I am trying to read the registry key by using WMI. I have tried with following code but i am unable to get the registry key value.
Can anyone help me regarding this problem.
ConnectionOptions oConn = new ConnectionOptions();
System.Management.ManagementScope scope = new System.Management.ManagementScope(@"\\" +hostname + @"\root\cimv2", oConn);
scope.Connect();
ManagementClass registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("GetStringValue");
inParams["sSubKeyName"] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework";
inParams["sValueName"] = "InstallRoot";
ManagementBaseObject outParams = registry.InvokeMethod("GetStringValue", inParams, null);
if (outParams.Properties["sValue"].Value != null)
{
output = outParams.Properties["sValue"].Value.ToString();
}
Note: i want to read the registry keys by using WMI only
Hi,
I think below url will help to you.
http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/30db8534-0a15-4ba7-9b55-7ab772633d68[^]
Thanks,
Suneel Kumar SVS.
这篇关于使用WMI读取注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!