Problem in using EnableStatic....

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

Ivan Brugiolo [MSFT]

In W2K3 the EnableStatic uses the same interfaces used by the
NetworkConnection UI
for uniformity of behaviors and errors. Your error below is

#define NETCFG_E_NO_WRITE_LOCK
MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0xA024)

that is normally caused by one other application holding the write lock in
the TCP notify object.
Do you have the NetworkProperties page opened ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top