?
Solved

Get the Process ID from a handle

Posted on 2003-03-17
8
Medium Priority
?
440 Views
Last Modified: 2010-04-04
I while back I think Madshi wanted to know how to get the Process ID from a handle, see this link...

http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_10073493.html

This works well in 98, but not under XP (probably not NT and above)...  Is there a way of doing this for NT and above?

0
Comment
Question by:Chris Nillissen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:MrGhost
ID: 8157748
check:
1 - Using the GetWindowThreadProcessId()
2 - Using the ToolHelp API
0
 
LVL 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 8167194
Look on the net for NtQueryProcessInformation.
0
 

Expert Comment

by:MartinVenter
ID: 8216625
Hi ChrisNillessen,

Dont know if your question has been answerd but here is my answer anyway.
Below is a function that uses GetWindowThreadProcessID like MrGhost suggested.

function GetProcID(Handle: THandle): THandle;
var
  ProcID: THandle;
begin
  GetWindowThreadProcessID(Handle, @ProcID);
  Result := ProcID;
end;

Regards,
Martin
0
 

Expert Comment

by:CleanupPing
ID: 9316734
ChrisNillissen:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 10613242
MrGhost and MartinVenter both misunderstood the question. They both explained how to get the process id from a window handle. But the question was how to get the process id from a process handle. This can be done only by using NtQueryInformationProcess, as I suggested.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question