您好我正在使用Visual Studio C ++。
这将解释很多:
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT SerialNumber FROM Win32_DiskDrive"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hres))
{
cout << "Query for harddisk sn failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
// Get the value of the Name property
hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0);
wcout << "HDD SN : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
pclsObj->Release();
}
这将是Cout Harddisk的序列号。我的主要问题是如何同时选择多个查询以便我可以输出多个结果
我需要添加例如“SELECT SerialNumber FROM Win32_BaseBoard”并同时输出HDD和主板序列号
帮助xD