Determining order of windows opened
Through the windows API I can get the list of all windows which are currently open but it seems that the IntPtr's don't come back in any specific order. I was wondering if there is a way to get the windows in the order in which they were opened. For instance if I open 2 IE windows followed by a notepad window, when I retrieve the list of windows I would like the 2 IE windows to be before the notepad window. I am doing this in C#.
Handle values are obfuscated pointers, you cannot rely on their value at all. And they get recycled.
The long distance shot is GetWindowThreadProcessId() to get the ID of the thread that owns the window. OpenThread() to get a handle to it. GetThreadTimes() to find out when that thread was created. CloseHandle() to clean up. The result is however but a guesstimate, do avoid wanting to ask such a question. Visit pinvoke.net for the declarations.