WMI connect

From: Buc (bucrepus_at_hotmail.com)
Date: 09/22/04


Date: Wed, 22 Sep 2004 17:06:18 -0500

I used the sample posted on this group some time ago by a Microsoft guy. I
am essen. trying to get the processer_id from WMI. I wrote a dll to send me
the processer_id. Works fine on my machine but no other Win2000 machine with
latest SP. The 1st call in DLL fails. I checked the 2 WMI services,
running... I even installed the WMI redistrib. package on the test machines
with no luck. Is there anything else to do to get this stuff to work without
installing Visual studio on each machine. Please help..
Heres code that fails on all machines but mine.

IWbemServices* ConnectToWMINamespace(BSTR bstrNamespace);
IEnumWbemClassObject* pEnum;

char * _stdcall GetProcID()
{
  HRESULT hr;
  _bstr_t bstrNamespace(L"\\\\.\\root\\cimv2");
  _bstr_t bstrWQL(L"WQL");
  _bstr_t bstrQuery;
  /* Lets connect to the cimv2 namespace in WMI */
  IWbemServices* pWMIServices = ConnectToWMINamespace(bstrNamespace);

  if (pWMIServices == NULL)
  {
     MessageBox(NULL,"Unable to connect to service","ERROR",MB_SYSTEMMODAL);
<<blows up
      return 0;
  }
other code.....
}
Works every time on mine in release mode or through the dubugger mode.
Thanks...