Win32_NetworkAdapterConfiguration
Hi All,
I have to use Win32_NetworkAdapterConfiguration class for getting/setting Network properties.
eg: For enabling DHCP. ( call the member function EnableDHCP() of this class.).
For this i need to use the COM interface IWbemLocator.
And this interface requires Wbemuuid.lib.
Although this Wbemuuid.lib is present in my machine, i couldn't find its coresponding dll in my machine.
So when i call CoCreateInstance it fails saying class is not registered.
My machine is Windows NT4 (SP6).
Please help me out of this problem.
I called CoCreateInstance like this.
CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLocator)
Thanks in Advance
Cherian
Re: Win32_NetworkAdapterConfiguration
hr = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
For any MethodName related to DHCP, this call returns S_OK, but pInClass is NULL. Any other method names documented for Win32_NetworkAdapterConfiguration are ok: returns with a valid pointer. I am running it on Windows 7.
Anyone has any clues of why?
Re: Win32_NetworkAdapterConfiguration
pInClass will be NULL if there are no input parameters to the method. What method are you trying to get that has input parameters?
Start a new thread next time - instead of reviving an 11 year old thread :)
gg
Re: Win32_NetworkAdapterConfiguration
This is the section code:
BSTR MethodName = SysAllocString(L"EnableDHCP");
// BSTR MethodName = SysAllocString(L"EnableStatic");
IWbemClassObject * pInClass = NULL;
IWbemClassObject * pInInst = NULL;
IWbemClassObject * pOutInst = NULL;
IWbemClassObject * pvClass = NULL;
VARIANT pathVar;
hres = pSvc->GetObject(L"Win32_NetworkAdapterConfiguration", 0, NULL, &pvClass, NULL);
if( hres != WBEM_S_NO_ERROR )
{
plogfile->WriteError(_T("Network: Failed to query Win32_NetworkAdapterConfiguration, error code: %x\r\n"), hres);
SysFreeString(MethodName);
return hres;
}
hres = pvClass->GetMethod(MethodName, 0, &pInClass, NULL);
if( hres != WBEM_S_NO_ERROR )
{
plogfile->WriteError(_T("Network: Failed to EnableDHCP method, error code: %x\r\n"), hres);
SysFreeString(MethodName);
return hres;
}
If the method name is EnableStatic, pInClass is valid pointer. Any methods related to DHCP for exampe, ReleaseDHCPLease, will return with pInClass as NULL.
Quote:
Originally Posted by
Codeplug
pInClass will be NULL if there are no input parameters to the method. What method are you trying to get that has input parameters?
Start a new thread next time - instead of reviving an 11 year old thread :)
gg
Re: Win32_NetworkAdapterConfiguration
I found out the issue. As EnableDHCP doesn't require parameter inputs, pvClass->GetMethod(MethodName, 0, &pInClass, NULL); returns with NULL pointer for pInClass.
Quote:
Originally Posted by
z160896
This is the section code:
BSTR MethodName = SysAllocString(L"EnableDHCP");
// BSTR MethodName = SysAllocString(L"EnableStatic");
IWbemClassObject * pInClass = NULL;
IWbemClassObject * pInInst = NULL;
IWbemClassObject * pOutInst = NULL;
IWbemClassObject * pvClass = NULL;
VARIANT pathVar;
hres = pSvc->GetObject(L"Win32_NetworkAdapterConfiguration", 0, NULL, &pvClass, NULL);
if( hres != WBEM_S_NO_ERROR )
{
plogfile->WriteError(_T("Network: Failed to query Win32_NetworkAdapterConfiguration, error code: %x\r\n"), hres);
SysFreeString(MethodName);
return hres;
}
hres = pvClass->GetMethod(MethodName, 0, &pInClass, NULL);
if( hres != WBEM_S_NO_ERROR )
{
plogfile->WriteError(_T("Network: Failed to EnableDHCP method, error code: %x\r\n"), hres);
SysFreeString(MethodName);
return hres;
}
If the method name is EnableStatic, pInClass is valid pointer. Any methods related to DHCP for exampe, ReleaseDHCPLease, will return with pInClass as NULL.