Window or Handle creation time?


I particurlarly need to know when a window was created or displayed. This is essential for various "MessageBox"es that popup from random programs with a text in it but without any timecode saying when this message popped up. This is especially annoying on long-time tasks where nobody is in front of the system.

So - is there any way to get the creation time of a window? I don't mean the creation time of a whole process (and to be clear: I don't mean the startup time of Windows itself, too). And sadly it seems that MessageBoxes also won't create a thread (which definitly has a creation time that can be read with ProcExp).

My problem would be indirectly solved if somebody can guarantee that the WinAPI (or else) was never meant to know the creation time of a handle. In this case it can't be helped of course.

Thanks for reading and thinking :-)
LVL 12
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HI AmigoJack,

I don't think there's a possibility to find the creation time of a HANDLE - at least I never heard or read about something to do so.

But, maybe you could implement a system wide hook which can log all window creation/deletion times you need - to do so you would need a WH_CBT-hook proc.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AmigoJackAuthor Commented:

yes it's obvious to write an own helper app which logs all window creations if nothing helpful exists. However - isn't there any other chance? Running hooks for this little purpose is like shooting sparrows with canons ;-)
Sorry, I don't know any other method. AFAIK handles in windows are just 32-bit values handled by the OS. I guess these handles are stored/used in a way that they can be created/accessed/destroyed with maximum performance since every system object is represanted by a handle. Storing a time-stamp or something similar with a handle would be a overhead.
There indeed is no such thing as a creation time for a handle - but I'd rather go for a WH_GETMESSAGE hook, so you can intercept WM_CREATE messages sent to a MessageBox by identifying their Window Class name using 'GetClassName()' and the MSG::time parameter. See e.g. ("Win32 Hooks")
AmigoJackAuthor Commented:
Thanks for contributing :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.