Announcement

Collapse
No announcement yet.

GetProcessID from Handle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GetProcessID from Handle

    I have spent the good part of a day looking for how to get the PID when all I have is a Handle. There seems to be tons of examples how to get the Handle when all you have is the PID, but not the other way around.

    So far my best lead is my own code from the Source Code Forum (ok, wo that will be the blind leading the blind, thank god I commented as much as I did). Unfortunately it uses all the "Undocumented" API's

    So I wondered if there is a documented and more reliable way to get the PID of a program already running, and I did not start it, but I am looking for it.

    Any ideas????
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    http://msdn.microsoft.com/en-us/libr...15(VS.85).aspx

    (The deceptively-named "GetProcessID" function)

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      (The deceptively-named "GetProcessID" function)
      Hence my post of The deceptively-named "GetProcessID" which should be found in Kernel32.dll but I have not found by default any *.inc files that have this???

      The docs are elusive to how to declare it if it was an oversight, and Win32Api.inc does not seem to have it, so I thought I would post before complaining some sort of "Bug" when clearly its an oversight
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


      • #4
        Code:
        DECLARE FUNCTION GetProcessId LIB "KERNEL32.DLL" ALIAS "GetProcessId" ( _
           BYVAL Process AS DWORD _                             ' __in HANDLE Process
         ) AS DWORD                                             ' DWORD
        It needs Windows XP SP1 or greater, and the include files distributed with the compiler are only updated up to Windows 2000.
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          > Win32Api.inc does not seem to have it

          Win32API.INC is not a valid source for Windows API Information. It is a convenience for users of the PowerBASIC, Inc. compilers. (a LARGE convenience!)

          Try: http://msdn.microsoft.com/en-us/default.aspx
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X