diff --git a/handle/handle.cpp b/handle/handle.cpp index 6e47483..a7f7b6f 100644 --- a/handle/handle.cpp +++ b/handle/handle.cpp @@ -9,6 +9,7 @@ LONG_PTR GetPID(const TCHAR* processName) success = Process32First(snapshot, &pe); if (_tcscmp(processName, pe.szExeFile) == 0) { + CloseHandle(snapshot); return pe.th32ProcessID; } while (success) @@ -16,6 +17,7 @@ LONG_PTR GetPID(const TCHAR* processName) success = Process32Next(snapshot, &pe); if (_tcscmp(processName, pe.szExeFile) == 0) { + CloseHandle(snapshot); return pe.th32ProcessID; } }