views:

611

answers:

3

Given a handle of type HWND is it possible to confirm that the handle represents a real window?

+8  A: 

There is a function IsWindow which does exactly what you asked for.

BOOL isRealHandle = IsWindow(unknwodnHandle);

Look at this link for more information.

Serge
+1  A: 

Generally no. By the time you've got confirmation that a Window is valid another process/thread my come along and remove it for you.

graham.reeds
A: 

Graham is right .. some time in race it is very tough to rely on IsWindow API

alok