有我的进程列表:
public class lab2 {
public static void main(String args[]) {
Kernel32 kernel32 = Kernel32.INSTANCE;
User32 user32 = User32.INSTANCE;
Tlhelp32.PROCESSENTRY32.ByReference processEntry = new Tlhelp32.PROCESSENTRY32.ByReference();
WinNT.HANDLE snapshot = kernel32.CreateToolhelp32Snapshot(
Tlhelp32.TH32CS_SNAPPROCESS, new WinDef.DWORD(0));
char path[] = new char[512];
HWND hWnd = User32.INSTANCE.GetWindowModuleFileName(hWnd, path, 512);
try {
while (kernel32.Process32Next(snapshot, processEntry)) {
System.out.println(Native.toString(processEntry.szExeFile)
+ "\t" + Native.toString(path));
}
} finally {
kernel32.CloseHandle(snapshot);
}
}
}
我试图将变量路径设置为文件的完整路径。我在哪里出错?HWND hWnd = User32.INSTANCE.GetWindowModuleFileName(hWnd, path, 512);
怎么做才对?谢谢你。