none
What is the difference between a "PID", "Handle" and a "TID"? RRS feed

  • Question

  • I am creating an application that needs to know what color the pixel is under the mouse when it is clicked.  After reading many sites I found that I need to get the Handle of the application and then create a bitmap then use the bitmap class to get the pixel color. 

    I downloaded the software called "Process Explorer" so that I can see the application information.  There is a lot of information there and I'm confused.  Is a handle number the same as the PID?  I also found that there is a TID. 
    I would like to understand all of this so that I can write my own app and know what to do.  This question is probably very broad but a quick explanation in laymans terms would be great.  Or just a site I can go to and read about it would help.

    Thanks in advance,
    Steve
    Friday, April 25, 2008 3:56 PM

Answers

  • PID is short for Process ID. No two processes have the same process ID.

    The handle is the address in memory where the operating system has stored information about the process. Usually a data structure with information such as the executable that is running on the process, the status of the process, the start time of the process and even the process ID as well as some other information.

    So while the PID and Handle uniquely identify each process their purpose is different. Although I believe in .Net it's very rare (and probably discouraged) that you use the handle directly.

    TID is short for Thread ID. A process can have multiple threads.
    Friday, April 25, 2008 9:55 PM
  • You're on the wrong "thread" with this.  You'll want to copy bits off the screen.  Use Graphics.CopyFromScreen() to copy the bit(s).  Use Bitmap to store the bits and Bitmap.GetPixel() to read the pixel value.  Use Control.Capture to make sure you get mouse messages even though the mouse is located off your GUI.  And Control.MousePosition to find out where the mouse is located on the screen.
    Friday, April 25, 2008 11:24 PM
    Moderator

All replies

  • PID is short for Process ID. No two processes have the same process ID.

    The handle is the address in memory where the operating system has stored information about the process. Usually a data structure with information such as the executable that is running on the process, the status of the process, the start time of the process and even the process ID as well as some other information.

    So while the PID and Handle uniquely identify each process their purpose is different. Although I believe in .Net it's very rare (and probably discouraged) that you use the handle directly.

    TID is short for Thread ID. A process can have multiple threads.
    Friday, April 25, 2008 9:55 PM
  • You're on the wrong "thread" with this.  You'll want to copy bits off the screen.  Use Graphics.CopyFromScreen() to copy the bit(s).  Use Bitmap to store the bits and Bitmap.GetPixel() to read the pixel value.  Use Control.Capture to make sure you get mouse messages even though the mouse is located off your GUI.  And Control.MousePosition to find out where the mouse is located on the screen.
    Friday, April 25, 2008 11:24 PM
    Moderator
  • Mind you, a handle is not an address in memory.  It's called a handle because it's opaque.  It's an indirect index into the process' handle table, which in turn contains the pointer to the kernel data structure.
    Saturday, April 26, 2008 10:04 AM