The following Code builds correctly, but receives the error System.AccessViolationException. If any one can help with this, or provide additional resources. I used program with pick basic when I was working for a company that made production management software, now I'm a network engineer so my knowledge base here is limited. I need some better documentation on how to program for the wmi in C++. I found a lot with vb and C# info, but I have to use C++ which the msdn documentation is horrific.

// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----

/////////////////////////////////////////
// For example, get the processor load//
///////////////////////////////////////

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

if (FAILED(hres))
{
cout << "Query for the Processor failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}

// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------

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"LoadPercentage", 0, &vtProp, 0, 0);
wcout << " Load Percentage : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
}