I have connected to ROOT\\CIMV2 WMI namespace and after connecting run the following code.

Code:
IEnumWbemClassObject* pEnumerator = NULL;
    hres = pSvc->ExecQuery(
        bstr_t("WQL"), 
        bstr_t("Select * from Win32_Process"),
        WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
        NULL,
        &pEnumerator);
After this I used while (pEnumerator) to get the name of each of the running processes.

I want to get the process id for just the explorer process but I can not get the string comparison to work.

I have tried the following:

Code:
VARIANT vtProp;

hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
        
string procToFind = "explorer.exe";
string currentProc = (char *)vtProp.bstrVal;

wcout << vtProp.bstrVal << " = " << procToFind.c_str() << " " << procToFind.compare(currentProc) << endl;
This prints out "explorer.exe = explorer.exe 1".

Why are these two not equal? I am new to C and am confused by all the different types of strings.

The only modification is the query I ran. Thanks for your help