对于默认注册表视图,我无法获取数据,因此我需要进入Registry64
,并且使用system.Management
类,这是WMI获取注册表值的方法。
有人可以建议在哪里放RegistryView.Registry64
支票吗?
ConnectionOptions oConn = new ConnectionOptions();
ManagementScope scope = new ManagementScope("\\\\.\\root\\default", oConn);
scope.Connect();
ManagementClass registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("GetStringValue");
inParams["sSubKeyName"] = "SOFTWARE\\Intel\\Server";
inParams["sValueName"] = "Version";
var outParams = registry.InvokeMethod("GetStringValue", inParams, null).Properties["sValue"].Value;
if (outParams != null)
{
Console.WriteLine(outParams.ToString());
}