StdRegProv-WMI代码生成器 [英] StdRegProv - WMI Code Generator
问题描述
您好,
我正在尝试使用StdRegProv的WMI代码生成器通过注册表获取已安装应用程序的列表.使用该工具,我得到以下信息:
ManagementObject classInstance =
新的ManagementObject(``root \\ DEFAULT'',
获取方法
的参数内的参数ManagementBaseObject inParams =
classInstance.GetMethodParameters("EnumValues")和
<2147483650;
inParams ["sSubKeyName"] ="SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\";
ManagementBaseObject outParams =
classInstance.InvokeMethod("EnumValues",inParams,null);
br>控制台.Wr iteLine("ReturnValue:" + outParams ["ReturnValue"]);
Console.WriteLine("sNames:" + outParams ["sNames"]);
; Types]);
但是在ManagementObject类上,在运行时出现以下错误:
指定的参数不在有效值范围内.
参数名称:path
有人可以为我指出解决该问题所需的正确方法吗?
谢谢
Hi there,
I'm experimenting with the WMI code generator using StdRegProv to get a list of installed applications via the registry. Using that tool I get the following:
ManagementObject classInstance =
new ManagementObject("root\\DEFAULT",
"StdRegProv", null);
// Obtain in-parameters for the method
ManagementBaseObject inParams =
classInstance.GetMethodParameters("EnumValues");
// Add the input parameters.
inParams["hDefKey"] = 2147483650;
inParams["sSubKeyName"] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod("EnumValues", inParams, null);
// List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
Console.WriteLine("sNames: " + outParams["sNames"]);
Console.WriteLine("Types: " + outParams["Types"]);
But on the ManagementObject class I get the following error on runtime:
Specified argument was out of the range of valid values.
Parameter name: path
Can anyone please point me into the right direction to what I need to do to solve this problem?
Thanks
推荐答案
你好,
我想您的错误是在创建ManagementObject的过程中发生的.
I suppose that your error is happening during the creation of the ManagementObject.
对于具有3个参数的构造函数,参数路径是第二个参数路径:StdRegProv
With a constructor having 3 parameters, the parameter path is the 2nd one that's to say : StdRegProv
我将尝试在计算机上重复您的问题(有关WMI的每件事对我来说都很有趣)
I will try to repeat your problem on my computer ( every thing about WMI is interesting me )
您的操作系统是哪个(XP,Vista或Windows Server 2003)?
Which is your OS ( XP,Vista or Windows Server 2003 ) ?
祝你愉快
这篇关于StdRegProv-WMI代码生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!