Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. EnumProcesses

EnumProcesses

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dellthinker
    wrote on last edited by
    #1

    Hi all, quick question. I've read the MSDN library definition for this API and all i really want to know is can i use it to find a running program or not. Still searhing for a example of this API in use so its still very un-clear to me. Thanx in advance!

    H L 3 Replies Last reply
    0
    • D dellthinker

      Hi all, quick question. I've read the MSDN library definition for this API and all i really want to know is can i use it to find a running program or not. Still searhing for a example of this API in use so its still very un-clear to me. Thanx in advance!

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      EnumProcesses shows each process on the system but what do you need exactly?

      1 Reply Last reply
      0
      • D dellthinker

        Hi all, quick question. I've read the MSDN library definition for this API and all i really want to know is can i use it to find a running program or not. Still searhing for a example of this API in use so its still very un-clear to me. Thanx in advance!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        DWORD dwPID[16860]; //maximim amount of PIDS possible DWORD dwRet; DWORD dwNumProcesses; if (TRUE == EnumProcesses(dwPID,sizeof(dwPID),&dwRet)) { dwNumProcesses = dwRet / (sizeof(DWORD); for(int i =0;i < dwNumProcesses;++i) { printf(_T("Process ID = %d"),dwPID[i]; } }
        Best Wishes, -Randor (David Delaune)

        1 Reply Last reply
        0
        • D dellthinker

          Hi all, quick question. I've read the MSDN library definition for this API and all i really want to know is can i use it to find a running program or not. Still searhing for a example of this API in use so its still very un-clear to me. Thanx in advance!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          This function can check if a process is running by checking the executable name. You may want to add additional checking such as window class enumeration or enumeration of known loaded modules. BOOL IsExecutableRunning(TCHAR *lpszExe) { HANDLE hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); PROCESSENTRY32 processInfo; processInfo.dwSize=sizeof(PROCESSENTRY32); while(Process32Next(hSnapShot,&processInfo)!=FALSE) { if(processInfo.th32ProcessID > 12 && _tclen(processInfo.szExeFile) > 0) { if(_tcscmp(processInfo.szExeFile,lpszExe) == 0) { CloseHandle(hSnapShot); return TRUE; } } } CloseHandle(hSnapShot); return FALSE; } Best Wishes, -Randor (David Delaune)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups