갱스
[WinAPI] Get Executable Path from PID 본문
- #include <Psapi.h>
- #pragma comment(lib, "psapi.lib")
- ///////////////////////////////////////
- TCHAR buf[500] = { 0 };
- HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
- DWORD len = sizeof(buf) / sizeof(TCHAR);
- QueryFullProcessImageName(hProcess, 0, buf, &len);
- wcout << buf << endl;
- CloseHandle(hProcess);
예를 들어
notepad 프로세스의 pid를 알 수 있을 때
C:\Windows\System32\notepad.exe
와 같이 executable image path를 뽑아내는 코드다
'Windows' 카테고리의 다른 글
Effective C# (0) | 2017.12.22 |
---|