WMI

Móczár Gábor <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <[email protected]>
Hi!

I have already read "Using with WMI COM classes" topic, but I have no success...
Is there anybody how can query WMI to get e.g. free memory from op.sys. class?

I have tried the ExecQuery method, but it returns a SWbemObjectSet, and I do not know how to enumerate it...
I have also tried to get the Win32_OperatingSystem object directly like: xxx.invoke("Get", "Win32_OperatingSystem"), but it always returns null.
I have success, with Win32_Services class, e.g. I am able to start/stop a service:
        DispatchPtr lWMISWbemLocator = null;
        lWMISWbemLocator = new DispatchPtr("WbemScripting.SWbemLocator");
        DispatchPtr lSWbemServices = (DispatchPtr) lWMISWbemLocator.invoke("ConnectServer", "127.0.0.1", "root\\cimv2", "", "");
                DispatchPtr lSWbemObjectService = (DispatchPtr) lSWbemServices.invoke("Get", "Win32_Service='alerter'");
        ....
        result = (Integer) getDispatcher("alerter").invoke("start");

Any help is greatly appreciated!

THX

Gabor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.