blob: 60dba4d241597ec9c1c02b9aafb69e6129b01411 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "ConnectionNotify.h"
void pid2name(DWORD procid, TCHAR *buffer, size_t bufLen)
{
HANDLE hSnap = INVALID_HANDLE_VALUE;
HANDLE hProcess = INVALID_HANDLE_VALUE;
PROCESSENTRY32 ProcessStruct;
ProcessStruct.dwSize = sizeof(PROCESSENTRY32);
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap == INVALID_HANDLE_VALUE)
return;
if (Process32First(hSnap, &ProcessStruct) == FALSE)
return;
do {
if (ProcessStruct.th32ProcessID == procid) {
_tcsncpy_s(buffer, bufLen, ProcessStruct.szExeFile, _TRUNCATE);
break;
}
}
while( Process32Next( hSnap, &ProcessStruct ));
CloseHandle( hSnap );
}
|