CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Location
    Darmstadt, FRG
    Posts
    87

    Handle of process to process id

    When spawnX() starts a process in asynchronous mode it returns the handle of the new process. Somne functions dealing with processes e.g. GetWindowsThreadProcessID() return the processes ID. What's the relationship between handle and id? Is there a function for transformation?

    Thanks in advance for your reply!

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Handle of process to process id

    An ID identifies the process and/or thread in your current windows session. To gain access to a thread/process (e.g. to check its status, kill it and so on) you need to "open" the Process. The open process takes the ID (to lookup the right process you are looking for) and returns the handle. The handle may store additional information along: Do you have termination rights? Do you have read/write rights? And so forth. The handle then may be passed to other functions like TerminateThread and so on.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: Handle of process to process id

    There is no conversion from handle to ID, but one can call OpenProcess(ID) to get the handle.

    If you use CreateProcess to spawn/create the process, then you get the handle and ID both in PROCESS_INFORMATION structure.
    Regards,
    Ramkrishna Pawar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured