在哪里放置RegistryView.Registry64检查

时间:2019-04-05 11:10:48

标签: c#

对于默认注册表视图,我无法获取数据,因此我需要进入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());
            }

0 个答案:

没有答案