Summary: I'm trying to call a method in my driver using WMI from a user app (driver property page), but I keep getting an WBEM_E_FAILED (general error) when the COM function IWbemServices->ExecMethod(). I can see this class, it's properties, and the method itself, using the MS tool WBEMTEST.EXE. WBEMTEST returns the same error. I have two other classes which contian data and an event class; no problems, I can get the data and fire events

I've looked at the WMI sample in the DDK and everything I'm doing looks OK. Can anyone direct me to some additional driver samples? Am I missing anything obvious

Thanks in advance

Dean A. Gereau
Golden Bits Software, Inc

=====================

Details: My class is defined as follows

[Dynamic, Provider("WMIProv"), WMI
Description("JAM Methods.")
guid("{94a8cec5-7490-4f72-8c21-ba44ec8dbc95}")
locale("MS\\0x409")
class JAM_Method

[key] string InstanceName
boolean Active

/* Procedure to reset statistics *
[WmiMethodId(1), Implemented
static, read, write
Description("Reset JAM Statistics")
void ResetJAMStatistics([in, Description("WMI requires a parameter")] uint32 Hack)
}

My user app

HRESULT hResult
CComBSTR bstrMethod("ResetJAMStatistics")
CComBSTR bstrClass("JAM_Methods")
CComPtr<IWbemClassObject> spClass
CComPtr<IWbemClassObject> spInParmsDef
CComPtr<IWbemClassObject> spNewInstance
CComVariant varInput(41)

// call WMI procedure to rest sta
if(m_pIWbemServices == NULL
return

hResult = m_pIWbemServices->GetObject(bstrClass, 0, NULL, &spClass, NULL)

if(!SUCCEEDED(hResult)
return

if(!SUCCEEDED(spClass->GetMethod(bstrMethod, 0, &spInParmsDef, NULL))
return

// spawn an instanc
if(!SUCCEEDED(spInParmsDef->SpawnInstance(0, &spNewInstance))
return

if(!SUCCEEDED(spNewInstance->Put(L"Hack", 0, &varInput, 0))
return

// execute method -- FAILS HERE!
hResult = m_pIWbemServices->ExecMethod(bstrClass, bstrMethod, 0, NULL, spNewInstance, NULL, NULL)

Re: WMI - Calling a Method by Walter

Walter
Tue May 04 22:35:50 CDT 2004

Dean A. Gereaux wrote:
> I've looked at the WMI sample in the DDK and everything I'm doing looks OK. Can anyone direct me to some additional driver samples? Am I missing anything obvious?

There's a sample of a method call in my book, named WMIEXTRA. See also
the prose at pp. 530-31.

--
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com