Notice
Recent Posts
Recent Comments
Link
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Tags
more
Archives
Today
Total
관리 메뉴

갱스

[WinAPI] Get Executable Path from PID 본문

Windows

[WinAPI] Get Executable Path from PID

pknam 2015. 2. 13. 16:44

 



  1. #include <Psapi.h>
  2. #pragma comment(lib, "psapi.lib")
  3. ///////////////////////////////////////
  4. TCHAR buf[500] = { 0 };
  5. HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
  6. DWORD len = sizeof(buf) / sizeof(TCHAR);
  7.  
  8. QueryFullProcessImageName(hProcess, 0, buf, &len);
  9. wcout << buf << endl;
  10.  
  11. CloseHandle(hProcess);

 

 

예를 들어

notepad 프로세스의 pid를 알 수 있을 때

C:\Windows\System32\notepad.exe

와 같이 executable image path를 뽑아내는 코드다

'Windows' 카테고리의 다른 글

Effective C#  (0) 2017.12.22
Comments