Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 其中Microsoft.Management.Infrastructure_C#_Wmi - Fatal编程技术网

C# 其中Microsoft.Management.Infrastructure

C# 其中Microsoft.Management.Infrastructure,c#,wmi,C#,Wmi,我需要得到硬盘信息,我想使用WMI 来自msdn的示例 using Microsoft.Management.Infrastructure; ... string Namespace = @"root\cimv2"; string className = "Win32_LogicalDisk"; CimInstance myDrive = new CimInstance(className, Namespace); 我正在使用Visual Studio 2015。我在测试WMI的解决方案中创

我需要得到硬盘信息,我想使用WMI

来自msdn的示例

using Microsoft.Management.Infrastructure;
...
string Namespace = @"root\cimv2";
string className = "Win32_LogicalDisk";

CimInstance myDrive = new CimInstance(className, Namespace);

我正在使用
Visual Studio 2015
。我在测试WMI的解决方案中创建了一个
控制台应用程序。没有Microsoft.Management.Infrastructure,如何添加它?

您是否添加了对Microsoft.Management.Infrastructure.dll的引用?(如列表顶部所述。)

是否添加了对Microsoft.Management.Infrastructure.dll的引用?(如图顶部所示。)

您是对的,顺便说一句,此链接是有帮助的,仅供参考:在Win 10和VS2015中,DLL位于C:\Program Files(x86)\Reference Assemblys\Microsoft\WMI\v1.0,由@Richard提供。您能帮助我吗:您是对的,顺便说一句,此链接是有帮助的,仅供参考:在Win 10和VS2015中,DLL位于C:\Program Files(x86)\@Richard提供的Reference Assemblies\Microsoft\WMI\v1.0可以帮助我吗:这显示了远程服务器的代码。您只需删除
连接选项
代码即可。这显示了远程服务器的代码。您只需删除
连接选项
代码即可。