static
HRESULT EnumInstPropNameWMI ( IN IWbemClassObject* piappObj,
OUT LPSAFEARRAY* ppsarProp )
{
if (NULL == ppsarProp || NULL == piappObj)
{
printf("Invalid argument\n");
return E_INVALIDARG;
}
// GetNames methods will create SAFEARRAY,
// but on entry this parameter must point to NULL
if (NULL != *ppsarProp)
{
SafeArrayDestroy(*ppsarProp);
delete *ppsarProp;
*ppsarProp = NULL;
if (WBEM_S_NO_ERROR == hres)
{
// get the input-argument class object and create an instance.
// pInClass == NULL indicates that no input parameters needed.
hres = pClassObj->GetMethod(bstrMethodName, 0, &pInClass, NULL);
if (WBEM_S_NO_ERROR == hres)
{
if( NULL != pInClass)
{
// create instance copy
if(WBEM_S_NO_ERROR == (hres=pInClass->SpawnInstance(0, &pInParam)) )
{
// set each property
for (long i = 0; i < size_t; ++i)
{
CComBSTR bstrPropName( (*csarrPropNames)[i].c_str() );
hres = pInParam->Put(bstrPropName, 0, &arrVarInArg[i], 0);
// DUF!!! Put failed, check the properties and their types
if (WBEM_S_NO_ERROR != hres)
break;
}
}
}
// finally call the method
if (WBEM_S_NO_ERROR == hres)
{
hres = piWmiServ->ExecMethod(bstrObjectPath,
bstrMethodName,
0,
NULL,
pInParam,
&pOutParam,
&pCallRrs);
}
}
}
// free all resources
if (NULL != pOutParam)
{
// but first we get the output parameters here
CComBSTR bstrClassObj;
hres = pOutParam->GetObjectText(0, &(bstrClassObj.m_str));
USES_CONVERSION;
printf("\n\nThe object text of the output object is:\n%s", OLE2T(bstrClassObj));
pOutParam->Release();
}
if (NULL != pClassObj) pClassObj->Release();
if (NULL != pInParam) pInParam->Release();
if (NULL != pInClass) pInClass->Release();
if (NULL != pOutClass) pOutClass->Release();
return hres;
}
HRESULT GetClassMethodsWMI ( IN IWbemClassObject* piappObj,
OUT ArgVector& csarrMethods)
{