要求根据可执行文件名来查找进程

解决方案 »

  1.   

    ////////代码如下:
    ///////////////////////////////
    HANDLE         hProcessSnap = NULL; 
    PROCESSENTRY32 pe32      = {0}; 
     
     //  Take a snapshot of all processes in the system.     hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);     if (hProcessSnap == INVALID_HANDLE_VALUE) 
            return (false); 
     
        //  Fill in the size of the structure before using it.     pe32.dwSize = sizeof(PROCESSENTRY32); 
     
        //  Walk the snapshot of the processes, and for each process, 
        //  display information.     if (Process32First(hProcessSnap, &pe32)) 
        { 
    do 
            { 
    if(strstr(pe32.szExeFile,"xxx.exe"){ ///处理的代码             
            } 
            while (Process32Next(hProcessSnap, &pe32)); 
           
        } 
         
        // could not walk the list of processes 
     
        // Do not forget to clean up the snapshot object.     CloseHandle (hProcessSnap);