Following is the code snippet:-
void CSystemData::setSystemData2()
{
IWbemLocator *pLocator = NULL;
IWbemServices *pNamespace = NULL;
IWbemClassObject *pClass = NULL;
IWbemClassObject *pInputParamClass = NULL;
IWbemClassObject *pInputParamInstance = NULL;
BSTR InstancePath = SysAllocString
(L"Win32_NetworkAdapterConfiguration=1");
HRESULT hr;
BSTR Path = SysAllocString(L"root\\cimv2");
BSTR ClassPath = SysAllocString
(L"Win32_NetworkAdapterConfiguration");
BSTR MethodName = SysAllocString(L"EnableStatic");
LPCWSTR Arg1Name = L"IpAddress";
VARIANT var1;
CreateOneElementBstrArray(&var1, L"192.168.0.100");
LPCWSTR Arg2Name = L"SubnetMask";
VARIANT var2;
CreateOneElementBstrArray(&var2, L"255.255.255.0");
CoInitialize(0);
CoCreateInstance(CLSID_WbemLocator, 0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator,
(LPVOID *)&pLocator);
hr = pLocator->ConnectServer(Path, NULL, NULL,
NULL, 0, NULL, NULL, &pNamespace);
hr = pNamespace->GetObject(ClassPath, 0, NULL,
&pClass, NULL);
hr = pClass->GetMethod(MethodName, 0,
&pInputParamClass, NULL);
hr = pInputParamClass->SpawnInstance(0,
&pInputParamInstance);
hr = pInputParamInstance->Put(Arg1Name, 0, &var1,
0);
hr = pInputParamInstance->Put(Arg2Name, 0, &var2,
0);
hr = pNamespace->ExecMethod(InstancePath,
MethodName, 0, NULL, pInputParamInstance, NULL, NULL);
pInputParamInstance->Release();
pInputParamClass->Release();
pClass->Release();
pNamespace->Release();
pLocator->Release();
}
void CSystemData::CreateOneElementBstrArray(VARIANT* v,
LPCWSTR s)
{
SAFEARRAYBOUND bound[1];
SAFEARRAY* array;
bound[0].lLbound = 0;
bound[0].cElements = 1;
array = SafeArrayCreate(VT_BSTR, 1, bound);
long index = 0;
BSTR bstr = SysAllocString(s);
SafeArrayPutElement(array, &index, bstr);
SysFreeString(bstr);
VariantInit(v);
v->vt = VT_BSTR | VT_ARRAY;
v->parray = array;
}
When that tool returns "Message Not Found", it means that the tool was
unable to find a matching error code
You can find the WMI Error codes at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
wmi_error_constants.asp
--
Wade Hasbrouck
Microsoft WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jackie Lau" <jacki...@philips.com> wrote in message
news:034c01c2d218$148d0730$a101...@phx.gbl...
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jackie Lau" <jacki...@philips.com> wrote in message
news:034c01c2d218$148d0730$a101...@phx.gbl...
>.
>
<jacki...@philips.com> wrote in message
news:08cb01c2d222$5d4577f0$2f01...@phx.gbl...
>.
>
HRESULT hr = NULL;
hr = CoInitializeSecurity(
NULL, // security descriptor
-1, // use this simple setting
NULL, // use this simple setting
NULL, // reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // authentication level
RPC_C_IMP_LEVEL_IMPERSONATE, // impersonation level
NULL, // use this simple setting
EOAC_NONE, // no special capabilities
0); // reserved
For more information see "Setting the Default Process Security Level using
C++" in the SDK.
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setting_the_default_process_security_level_using_c_.asp?frame=true
--
-Philip
This posting is provided "As Is" with no warranties, and confers no rights.
"Jackie Lau" <jacki...@philips.com> wrote in message
news:017901c2d2df$1befde40$a101...@phx.gbl...
>.
>