|
|
|
date: Thu, 17 Jul 2008 06:04:02 -0700,
group: microsoft.public.win32.programmer.wmi
back
how to execute non-static method on class instance?
Hello,
I have one question. If I want to execute static method in WMI, there is no
problem.
CComPtr<IWbemServices> pSvc = NULL;
// set pSvc through ConnectServer()
hres = pSvc->ExecMethod(_bstr_t(_T("BcdStore")), _bstr_t(_T("OpenStore")),
0, NULL, pInParamsObj, &pOutParamsObj, NULL);
This works since OpenStore is static method of BcdStore class.
But once I have BcdStore class instance (OpenStore method creates instance),
then I need to call its member method OpenObject. How to do this?
I get output param from static method OpenStore() - BcdStore object:
IWbemClassObject* pBcdObj;
But now how should I call OpenObject method on this BcdStore object?
hres = pSvc->ExecMethod(strObjectPath, _bstr_t(_T("OpenObject")), 0, NULL,
pInParamsObj, &pOutParamsObj, NULL);
How should I use pBcdObj to get strObjectPath used in previous line of code?
Or is there some other way how to call method on class instance?
Thanks very much.
Michal
date: Thu, 17 Jul 2008 06:04:02 -0700
author: trencan
RE: how to execute non-static method on class instance?
"trencan" wrote:
> Hello,
>
> I have one question. If I want to execute static method in WMI, there is no
> problem.
>
> CComPtr<IWbemServices> pSvc = NULL;
> // set pSvc through ConnectServer()
> hres = pSvc->ExecMethod(_bstr_t(_T("BcdStore")), _bstr_t(_T("OpenStore")),
> 0, NULL, pInParamsObj, &pOutParamsObj, NULL);
>
> This works since OpenStore is static method of BcdStore class.
>
> But once I have BcdStore class instance (OpenStore method creates instance),
> then I need to call its member method OpenObject. How to do this?
>
> I get output param from static method OpenStore() - BcdStore object:
> IWbemClassObject* pBcdObj;
>
> But now how should I call OpenObject method on this BcdStore object?
> hres = pSvc->ExecMethod(strObjectPath, _bstr_t(_T("OpenObject")), 0, NULL,
> pInParamsObj, &pOutParamsObj, NULL);
> How should I use pBcdObj to get strObjectPath used in previous line of code?
> Or is there some other way how to call method on class instance?
>
> Thanks very much.
>
> Michal
You could try using IWbemClassObject::Get() to get pBcdObj __PATH system
property.
--
urkec
date: Thu, 17 Jul 2008 07:56:01 -0700
author: urkec
RE: how to execute non-static method on class instance?
"urkec" wrote:
> "trencan" wrote:
>
> > Hello,
> >
> > I have one question. If I want to execute static method in WMI, there is no
> > problem.
> >
> > CComPtr<IWbemServices> pSvc = NULL;
> > // set pSvc through ConnectServer()
> > hres = pSvc->ExecMethod(_bstr_t(_T("BcdStore")), _bstr_t(_T("OpenStore")),
> > 0, NULL, pInParamsObj, &pOutParamsObj, NULL);
> >
> > This works since OpenStore is static method of BcdStore class.
> >
> > But once I have BcdStore class instance (OpenStore method creates instance),
> > then I need to call its member method OpenObject. How to do this?
> >
> > I get output param from static method OpenStore() - BcdStore object:
> > IWbemClassObject* pBcdObj;
> >
> > But now how should I call OpenObject method on this BcdStore object?
> > hres = pSvc->ExecMethod(strObjectPath, _bstr_t(_T("OpenObject")), 0, NULL,
> > pInParamsObj, &pOutParamsObj, NULL);
> > How should I use pBcdObj to get strObjectPath used in previous line of code?
> > Or is there some other way how to call method on class instance?
> >
> > Thanks very much.
> >
> > Michal
>
>
> You could try using IWbemClassObject::Get() to get pBcdObj __PATH system
> property.
>
> --
> urkec
That's right. Thank you very much. Only small comment, property __PATH was
empty, but __RELPATH is OK. Now it works.
Michal
date: Fri, 18 Jul 2008 02:01:01 -0700
author: trencan
|
|