Microsoft.Management.Infrastructure

Where the Microsoft.Management.Infrastructure

我需要获取硬盘信息,我想使用 WMI。

来自 msdn 的例子

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

CimInstance myDrive = new CimInstance(className, Namespace);

我正在使用 Visual Studio 2015。我在测试 WMI 的解决方案中创建了 console application。没有Microsoft.Management.Infrastructure,如何添加?

您是否添加了对 Microsoft.Management.Infrastructure.dll 的引用? (如上文所述MSDN page。)