| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include "precompile.h"
- #include "osutil.h"
- #include <TlHelp32.h>
- TOOLKIT_API int osutil_detect_unique_app(char **pNames, int nNum)
- {
- //const WCHAR *exe;
- HANDLE hSnapshot;
- int rc = TRUE;
- /*{
- WCHAR *t = (WCHAR*)_alloca(MAX_PATH);
- GetModuleFileNameW(NULL, t, MAX_PATH);
- exe = wcsrchr(t, '\\') + 1;
- }*/
- DWORD dwCurProcID = GetCurrentProcessId();
- hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if (hSnapshot) {
- PROCESSENTRY32 pe;
- pe.dwSize = sizeof(pe);
- if (Process32First(hSnapshot, &pe))
- {
- do
- {
- int i;
- for (i = 0; i < nNum; i++)
- {
- if (stricmp(&pe.szExeFile[0], pNames[i]) == 0 && pe.th32ProcessID != dwCurProcID)
- {
- rc = FALSE;
- break;
- }
- }
- } while (Process32Next(hSnapshot, &pe));
- }
- CloseHandle(hSnapshot);
- }
- return rc;
- }
|