JNA: get all windows processes command line -


looking way using jna list of running windows programs , command lines. there few tutorials on site (get list of processes on windows in charset-safe way) show how list of running program names i'm looking full command line. i've seen posts mention use of module32first functions can't seem find documentation on how use through jna. ideas?

edit:

i've tried below aforementioned post. idea want in-process way of iterating on running processes on windows , command lines. don't want use wmic.

   kernel32 kernel32 = (kernel32) native.loadlibrary(kernel32.class, w32apioptions.unicode_options);     tlhelp32.processentry32.byreference processentry = new tlhelp32.processentry32.byreference();                winnt.handle snapshot = kernel32.createtoolhelp32snapshot(tlhelp32.th32cs_snapprocess, new windef.dword(0));     try  {         while (kernel32.process32next(snapshot, processentry)) {                          system.out.println(processentry.th32processid + "\t" + native.tostring(processentry.szexefile));         }     }     {         kernel32.closehandle(snapshot);     } 

edit2:

looking @ windows api (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684839(v=vs.85).aspx) says below. i'm trying full path executable through jna. guess it's module32first function jna not have support not module32entry structure.

szexefile name of executable file process. retrieve full path executable file, call module32first function , check szexepath member of moduleentry32 structure returned. however, if calling process 32-bit process, must call queryfullprocessimagename function retrieve full path of executable file 64-bit process.

what have tried far? type mapping straightforward, , jna designed allow extend existing definitions augment them.

// original c typedef struct tagmoduleentry32 {   dword   dwsize;   dword   th32moduleid;   dword   th32processid;   dword   glblcntusage;   dword   proccntusage;   byte    *modbaseaddr;   dword   modbasesize;   hmodule hmodule;   tchar   szmodule[max_module_name32 + 1];   tchar   szexepath[max_path]; } moduleentry32, *pmoduleentry32;  // jna equivalent (unicode version) public interface mykernel32 extends kernel32 {     class moduleentry32 extends structure {         dword dwsize;         dword th32moduleid;         dword th32processid;         dword glblcntusage;         dword proccntusage;         pointer modbaseaddr;         dword modbasesize;         hmodule hmodule;         char[] szmodule = new char[max_modue_name32+1];         char[] szexepath = new char[max_path];         public string szmodule() { return native.tostring(this.szmodule); }         public string szexepath() { return native.tostring(this.szexepath); }         protected list getfieldorder() {             return arrays.aslist(new string[] {                 "dwsize", "th32moduleid", "th32processid", "glblcntusage", "proccntusage", "modbaseaddr", "modbasesize", "hmodule", "szmodule", "szexepath",             });         }     }      mykernel32 instance = (mykernel32)native.loadlibrary("kernel32", w32default_options);     boolean module32first(handle hsnapshot, moduleentry32 lpme); } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -