见如下CheckProcess函数: 用法: INT nProc = CheckProcess(_T("wininet.dll"); #include <windows.h> #include <tchar.h> #include <Tlhelp32.h> #include <stdio.h> BOOL CheckModules(DWORD dwPID, LPCTSTR szFileName) { HANDLE hModuleSnap = INVALID_HANDLE_VALUE; MODULEENTRY32 me32; BOOL bFound = false; // Take a snapshot of all modules in the specified process. hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID); if (hModuleSnap == INVALID_HANDLE_VALUE) { return FALSE; } // Set the size of the structure before using it. me32.dwSize = sizeof (MODULEENTRY32); // Retrieve information about the first module, // and exit if unsuccessful if (!Module32First(hModuleSnap, &me32)) { return FALSE; } // Now walk the module list of the process, // and display information about each module do { if (0 == _tcsicmp(me32.szModule, szFileName)) { bFound = TRUE; break; } } while (Module32Next(hModuleSnap, &me32)); // Don't forget to clean up the snapshot object. CloseHandle(hModuleSnap); return bFound; } INT CheckProcess(LPCTSTR szFileName) { HANDLE hProcessSnap; PROCESSENTRY32 pe32; INT nFind = 0; DWORD dwProcIdThis = GetCurrentProcessId(); // Take a snapshot of all processes in the system. hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap == INVALID_HANDLE_VALUE) { return FALSE; } // Set the size of the structure before using it. pe32.dwSize = sizeof(PROCESSENTRY32); // Retrieve information about the first process, // and exit if unsuccessful if (!Process32First(hProcessSnap, &pe32)) { CloseHandle(hProcessSnap); // Must clean up the snapshot object! return FALSE; } do { if (pe32.th32ProcessID == dwProcIdThis) { continue; } if (CheckModules(pe32.th32ProcessID, szFileName)) { _tprintf_s(_T("%s/n"), pe32.szExeFile); nFind++; } } while (Process32Next(hProcessSnap, &pe32)); CloseHandle(hProcessSnap); return nFind; }