笔记整理:
1 /*java获取cmd启动程序的PID */ 2 /*zzq581573832013-05-08上传*/ 3 //代码: 4 static interface Kernel32 extends Library{ 5 public static Kernel32 INSTANCE=(Kernel32) 6 Native.loadLibrary("kernel32", Kernel32.class); 7 public int GetProcessId(Long hProcess); 8 } 9 try { 10 Field f = p.getClass().getDeclaredField("handle"); 11 f.setAccessible(true); 12 long pid = Kernel32.INSTANCE.GetProcessId((Long) f.get(p)); 13 System.err.println(pid); 14 }
时间: 2024-10-20 03:56:17