Help for Win32_Service

babbo Mappeo <[email protected]> Fri, 2 Mar 2007 10:11:03 -0500
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <LISTSERV%[email protected]>
Hello to all!
I'm trying to print all win32 services, but i don't...
I'm able to execute the query, and i see that the result is correct (using
the property COUNT), but i'm not able to print this to the screen.
I put here my code.

import java.lang.*;
import java.io.*;
import org.jawin.*;
public class esempio4
{
 public static void main(String[] args)
 {
  try
  {
   String strQuery = "SELECT Name FROM Win32_Service";
   DispatchPtr lWMISWbemLocator = new DispatchPtr
("WbemScripting.SWbemLocator");
   DispatchPtr lSWbemServices = (DispatchPtr)
lWMISWbemLocator.invoke
("ConnectServer", "127.0.0.1", "root\\cimv2", "", "");
   DispatchPtr SWbemObjectSet = (DispatchPtr)
lSWbemServices.invoke("ExecQuery", strQuery);

   int recordCount = ((Integer)SWbemObjectSet.get
("Count")).intValue();
   System.out.println(recordCount);


   for (int i=0;i< recordCount; i++)
   {
   //here i wish to put the right sintax to print all
the result of my query
   }
  }
  catch (Exception e)
  {

   System.out.println("eccezione");
     e.printStackTrace();
  }
 }
}



Thanks a lot!!!!!