44. FAQ o Win API |
Q> How to learn хэндл a console window? A>
From: PSS ID Number: Q124103
HWND GetConsoleHwnd (void)
{
#define MY_BUFSIZE 1024
HWND hwndFound;
char pszNewWindowTitle [MY_BUFSIZE];
char pszOldWindowTitle [MY_BUFSIZE];
//we Remember console title
GetConsoleTitle (pszOldWindowTitle, MY_BUFSIZE);
//It is done a unique line of any crap
wsprintf (pszNewWindowTitle, "%d / % d",
GetTickCount (),
GetCurrentProcessId ());
//we Change title for the unique
SetConsoleTitle (pszNewWindowTitle);
//we wait a little
Sleep (40);
//It is found хэндл
hwndFound=FindWindow (NULL, pszNewWindowTitle);
//It is changed загловок windows reversely
SetConsoleTitle (pszOldWindowTitle);
return (hwndFound);
}
|
2000 (c) DM