how to find out the handler of a console window c 2b 2b

Solutions on MaxInterview for how to find out the handler of a console window c 2b 2b by the best coders in the world

showing results for - "how to find out the handler of a console window c 2b 2b"
Lindsay
01 Feb 2019
1HWND GetConsoleHwnd(void)
2   {
3       #define MY_BUFSIZE 1024 // Buffer size for console window titles.
4       HWND hwndFound;         // This is what is returned to the caller.
5       char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated
6                                           // WindowTitle.
7       char pszOldWindowTitle[MY_BUFSIZE]; // Contains original
8                                           // WindowTitle.
9
10       // Fetch current window title.
11
12       GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
13
14       // Format a "unique" NewWindowTitle.
15
16       wsprintf(pszNewWindowTitle,"%d/%d",
17                   GetTickCount(),
18                   GetCurrentProcessId());
19
20       // Change current window title.
21
22       SetConsoleTitle(pszNewWindowTitle);
23
24       // Ensure window title has been updated.
25
26       Sleep(40);
27
28       // Look for NewWindowTitle.
29
30       hwndFound=FindWindow(NULL, pszNewWindowTitle);
31
32       // Restore original window title.
33
34       SetConsoleTitle(pszOldWindowTitle);
35
36       return(hwndFound);
37   }
38
similar questions