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. EnumProcesss

EnumProcesss

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 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.
  • G Offline
    G Offline
    gekoscan
    wrote on last edited by
    #1

    I am trying to enumerate through all the process on running on my computer so I can run through them and get a handle to the process using OpenProcess() const DWORD dProcessCountGuesstimate = 200; DWORD ardProcessIds[dProcessCountGuesstimate]; DWORD dNumberOfProccessFound = 0; BOOL bReturn; bReturn = EnumProcesses(ardProcessIds, dProcessCountGuesstimate * sizeof(DWORD), &dNumberOfProccessFound); My question: Is there a better way other then guessing the number of process running on my computer. It kinda seems retarded to do it this way. Could someone please help. Thanks.

    S 1 Reply Last reply
    0
    • G gekoscan

      I am trying to enumerate through all the process on running on my computer so I can run through them and get a handle to the process using OpenProcess() const DWORD dProcessCountGuesstimate = 200; DWORD ardProcessIds[dProcessCountGuesstimate]; DWORD dNumberOfProccessFound = 0; BOOL bReturn; bReturn = EnumProcesses(ardProcessIds, dProcessCountGuesstimate * sizeof(DWORD), &dNumberOfProccessFound); My question: Is there a better way other then guessing the number of process running on my computer. It kinda seems retarded to do it this way. Could someone please help. Thanks.

      S Offline
      S Offline
      Scot Brennecke
      wrote on last edited by
      #2

      The problem is that the process set is very volatile. Processes get started and stopped very regularly, without user intervention. Even if you could determine immediately prior to calling EnumProcesses how many there were, there's no reason to believe the count will be the same by the time EnumProcesses executes. So, just make a wild-ass overestimate of the count, and hope for the best. I'm sure that with statistical analysis, you could determine a value that has a 99.99% probability of being sufficient. But memory is cheap, right? Make your best guess at how many there will be -- and double that. Even if you allow for 1000 processes, that's just 4000 bytes. Scot Brennecke Software Developer VC++ MVP

      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