TheCodeJunkie
TheCodeJunkie

Reputation: 9616

Check if handle belongs to the current process?

Is there any Win32 API to check if a given handle belongs to the current process?

Upvotes: 3

Views: 1434

Answers (2)

Anders
Anders

Reputation: 101569

A handle can "belong" to more than one process (Inherited handles in child process etc)

Upvotes: 1

Nick Dandoulakis
Nick Dandoulakis

Reputation: 43110

From a window handle you can use GetWindowThreadProcessId Function to get process id.
From a process handle you get the id with GetProcessId Function.

I don't know how easy is to get a process handle from some other handle. But I believe it'll have to do with kernel objects enumeration.

Upvotes: 3

Related Questions