#include <windows.h> #include <tlhelp32.h> #pragma comment(linker,"/subsystem:windows") bool ConfirmProcess(char* ProcessName) { HANDLE handle = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); PROCESSENTRY32 info={0}; info.dwSize = sizeof(PROCESSENTRY32); Process32First( handle, &info ); do { if( strcmp(info.szExeFile, ProcessName) == 0 ) { return true; } } while ( Process32Next( handle, &info ) ); CloseHandle(handle); return false; } int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // command line int nCmdShow // show state ) { char name[]="QQ.exe"; if ( ConfirmProcess(name) ) { MessageBox( 0, "存在", name, 0 ); } else { MessageBox( 0, "不存在", name, 0 ); } return 0; }