Hi guys, I'm trying to create code to determine how many PCI slots are currently on a system...available and used.
I have been trying to use the Win32_SystemSlot WMI class but it doesnt seem to be working properly.
instead of outputting useful shorts containing data according to this table http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx (scroll down to connector type) it gives me instead the output:Code://query systemslot IEnumWbemClassObject* pEnumerator = NULL; hres = pSvc->ExecQuery( bstr_t("WQL"), bstr_t("SELECT * FROM Win32_SystemSlot"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); //get class object IWbemClassObject *pclsObj; ULONG uReturn = 0; int noPCI = 0; int noAGP = 0; int noPCMIA = 0; //loop through system slots while (pEnumerator) { //next object HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); VARIANT vtProp; //get connecter type data (unsigned int16 array) hr = pclsObj->Get(L"ConnectorType", 0, &vtProp, 0, 0); //create uint16 array to store data unsigned short aShort[sizeof(vtProp)]; memcpy (aShort, (char*)(&vtProp), sizeof(aShort)); for(int i=0; i<sizeof(aShort); i++) cout << aShort[i] << endl; VariantClear(&vtProp);
8195 | -13364 | -13364 | -13364 | -5808 | 22 | -13364 | -13364 |
8195 | -13364 | -13364 | -13364 | -5808 | 22 | -13364 | -13364 |
8195 | -13364 | -13364 | -13364 | -5808 | 22 | -13364 | -13364 |
Which is the output for each iteration through the three system slots it loops through.
PCI slots should come up as 99. Any idea what i'm doing wrong?


Reply With Quote

Bookmarks