我的代码( 360 是我的流程ID):
HANDLE process = Kernel32.INSTANCE.OpenProcess(0x0400 | 0x0010,
false, 360);
if (process != null) {
int len = psapi.GetModuleFileNameExW(process, null, path,
1024);
if (len > 0) {
System.out.println(new String(path, 0, len));
} else {
System.out.println("GetModuleFileNameW failed");
}
} else {
System.out.println(kernel32.GetLastError());
}
路径会返回“?
”。我做错了什么?
答案 0 :(得分:0)
请改为尝试:
char path[] = new char[1024];
HANDLE process = Kernel32.INSTANCE.OpenProcess(0x0400 | 0x0010, false, 396);
if (process != 0)
{
int len = psapi.GetModuleFileNameExW(process, null, path, 1024);
if (len > 0)
System.out.println(new String(path, 0, len));
else
System.out.println("GetModuleFileNameW failed");
}
else
System.out.println("OpenProcess failed");