S
santosh
Hi All ,
I am facing a problem while using EnableStatic Method. The error
messages in Win2k and Win3k are as follows
1)In Win3k
ExecMethod hr = 0
EnableStatic method output :
instance of __PARAMETERS
{
ReturnValue = 2147786788;
};
2)In Win2k
ExecMethod hr = 0
EnableStatic method output :
instance of __PARAMETERS
{
ReturnValue = 94;
};
I am using the code as below
SetIPAddress(CComBSTR InstancePath , vecString IPAddress , vecString
SubnetMask)
{
IWbemClassObject *pMethod = NULL;
IWbemClassObject *pOutInst = NULL;
IWbemClassObject *pInInst = NULL;
CComBSTR methodName = _T("EnableStatic");
CComBSTR ArgIPAddress = _T("IPAddress");
CComBSTR ArgSubnetMask = _T("SubnetMask");
HRESULT hr;
do {
// Get the method we want to use in this class
hr = m_pClass->GetMethod(methodName, 0, &pMethod, NULL);
if (FAILED(hr))
{
Trace(_T("Failed pClass->GetMethod"));
break;
}
// Spawn an instance of the method so we can set it up
(parameters)
hr = pMethod->SpawnInstance(0, &pInInst);
if (FAILED(hr))
{
Trace(_T("Failed pMethod->SpawnInstance"));
break;
}
// Insert the ip address and subnetmask into an array
// EnableStatic() expects to receive the args in an array
hr = _PutArgInMethod(pInInst, ArgIPAddress, &IPAddress);
if(FAILED(hr))
{
Trace(_T("Failed to insert parameter %s into method"),
ArgIPAddress.m_str );
break;
}
hr = _PutArgInMethod(pInInst, ArgSubnetMask, &SubnetMask);
if(FAILED(hr))
{
Trace(_T("Failed to insert parameter %s into method"),
ArgIPAddress.m_str );
break;
}
// finally we get to call the actuall method we want
(EnableStatic())
hr = m_pNameSpace->ExecMethod(InstancePath, methodName, 0,
NULL, pInInst, &pOutInst, NULL);
#if _DEBUG
BSTR bstrText;
pOutInst->GetObjectText(0, &bstrText);
Trace(bstrText);
#endif
} while (FALSE);
RELEASE_AND_NULLIFY_REF(pMethod);
RELEASE_AND_NULLIFY_REF(pInInst);
RELEASE_AND_NULLIFY_REF(pOutInst);
return hr;
}
Is there any problem with the above code?? or is there any dependency
for using it??
If anyone has success in using EnableStatic , can u post the working
code snippet??
All the help will be very much appreciated..
Thanks
-Santosh
//KREnableStaticError
I am facing a problem while using EnableStatic Method. The error
messages in Win2k and Win3k are as follows
1)In Win3k
ExecMethod hr = 0
EnableStatic method output :
instance of __PARAMETERS
{
ReturnValue = 2147786788;
};
2)In Win2k
ExecMethod hr = 0
EnableStatic method output :
instance of __PARAMETERS
{
ReturnValue = 94;
};
I am using the code as below
SetIPAddress(CComBSTR InstancePath , vecString IPAddress , vecString
SubnetMask)
{
IWbemClassObject *pMethod = NULL;
IWbemClassObject *pOutInst = NULL;
IWbemClassObject *pInInst = NULL;
CComBSTR methodName = _T("EnableStatic");
CComBSTR ArgIPAddress = _T("IPAddress");
CComBSTR ArgSubnetMask = _T("SubnetMask");
HRESULT hr;
do {
// Get the method we want to use in this class
hr = m_pClass->GetMethod(methodName, 0, &pMethod, NULL);
if (FAILED(hr))
{
Trace(_T("Failed pClass->GetMethod"));
break;
}
// Spawn an instance of the method so we can set it up
(parameters)
hr = pMethod->SpawnInstance(0, &pInInst);
if (FAILED(hr))
{
Trace(_T("Failed pMethod->SpawnInstance"));
break;
}
// Insert the ip address and subnetmask into an array
// EnableStatic() expects to receive the args in an array
hr = _PutArgInMethod(pInInst, ArgIPAddress, &IPAddress);
if(FAILED(hr))
{
Trace(_T("Failed to insert parameter %s into method"),
ArgIPAddress.m_str );
break;
}
hr = _PutArgInMethod(pInInst, ArgSubnetMask, &SubnetMask);
if(FAILED(hr))
{
Trace(_T("Failed to insert parameter %s into method"),
ArgIPAddress.m_str );
break;
}
// finally we get to call the actuall method we want
(EnableStatic())
hr = m_pNameSpace->ExecMethod(InstancePath, methodName, 0,
NULL, pInInst, &pOutInst, NULL);
#if _DEBUG
BSTR bstrText;
pOutInst->GetObjectText(0, &bstrText);
Trace(bstrText);
#endif
} while (FALSE);
RELEASE_AND_NULLIFY_REF(pMethod);
RELEASE_AND_NULLIFY_REF(pInInst);
RELEASE_AND_NULLIFY_REF(pOutInst);
return hr;
}
Is there any problem with the above code?? or is there any dependency
for using it??
If anyone has success in using EnableStatic , can u post the working
code snippet??
All the help will be very much appreciated..
Thanks
-Santosh
//KREnableStaticError