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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get the Instance Handle from a Process ID?

How to get the Instance Handle from a Process ID?

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestion
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.
  • B Offline
    B Offline
    Billypon
    wrote on last edited by
    #1

    How could I get the Instance Handle from another Process ID? Maybe the Process has no any windows, so I can't use the GetWindowLong API. And I know nothing about the Module Name of the third Process, so I can't use the GetModuleHandle API,too. So,how could I get the Instance Handle from another Process ID?Or how could I get the Module Name of the third Process,that I can use the GetModuleHandle API for it?

    N 1 Reply Last reply
    0
    • B Billypon

      How could I get the Instance Handle from another Process ID? Maybe the Process has no any windows, so I can't use the GetWindowLong API. And I know nothing about the Module Name of the third Process, so I can't use the GetModuleHandle API,too. So,how could I get the Instance Handle from another Process ID?Or how could I get the Module Name of the third Process,that I can use the GetModuleHandle API for it?

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      Billypon wrote:

      How could I get the Instance Handle from another Process ID?

      Use OpenProcess API.

      HANDLE hProcHandle = ::OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwAnotherProcessID );
      ASSERT( hProcHandle );

      The first parameter specifies type of access needed. PROCESS_ALL_ACCESS won't always work. The type of action that you want to take on the remote process will determine the access needed. For eg: to terminate a process you will need PROCESS_TERMINATE access right or for ReadProcessMemory and WriteProcessMemory PROCESS_VM_**** rights. It's safe to have the SeDebugPrivilege enabled for your application if would like to do some advanced stuff with the other process. You might be interested to look up this article -> http://www.codeproject.com/useritems/processviewer.asp[^]


      Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com

      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