使用WMI获取串行硬盘

时间:2012-02-16 11:24:12

标签: c++ visual-studio-2010 wmi

我正在尝试通过WMI获取硬盘序列号,但我不确定这一点,如果我这样做一个查询:

// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
    bstr_t("WQL"), 
    bstr_t("SELECT * FROM Win32_diskdrive where index = 0"),
    WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
    NULL,
    &pEnumerator);

然后我再提出一个问题:

    IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
    bstr_t("WQL"), 
    bstr_t("SELECT * FROM Win32_PhysicalMedia"),
    WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
    NULL,
    &pEnumerator);

如何加入此信息以获取相同的驱动器?

1 个答案:

答案 0 :(得分:1)

为什么不用SELECT * FROM Win32_LogicalDisk查询?