|
Как получить
хэндл консоли.
VuDZ © (02.03.02 02:32)
1.
Win2k only: GetConsoleWindow()
2. win9x & win2k: GetConsoleText(), FindWindow()
-------------------------------
GetConsoleWindow
The GetConsoleWindow function retrieves the window handle used by the console associated
with the calling process.
Note Although this function was implemented in Windows 2000, it was not included in
the version of Wincon.h that was included with the Platform SDK for Windows 2000. To use
this function on Windows 2000, use the prototype included in this documentation, and
dynamically link to the function in Kernel32.dll.
HWND GetConsoleWindow (VOID);
Parameters
This function has no parameters.
Return Values
The return value is a handle to the window used by the console associated with the calling
process or NULL if there is no such associated console.
Requirements
Windows NT/2000 or later: Requires Windows 2000 or later.
Windows 95/98/Me: Unsupported.
Header: Declared in Wincon.h; include Windows.h.
Library: Use Kernel32.lib.
=============================================================
GetConsoleTitle
The GetConsoleTitle function retrieves the title bar string for th! e current console
window.
DWORD GetConsoleTitle(
LPTSTR lpConsoleTitle, // console title
DWORD nSize
// size of title buffer
);
Parameters
lpConsoleTitle
[out] Pointer to a buffer that receives a null-terminated string containing the text that
appears in the title bar of the console window.
nSize
[in] Specifies the size, in characters, of the buffer pointed to by the lpConsoleTitle
parameter.
Return Values
If the function succeeds, the return value is the length, in characters, of the string
copied to the buffer.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
To set the title bar string for a console window, use the SetConsoleTitle function.
Windows NT/2000 or later: This function uses either Unicode characters or 8-bit characters
from the console's current code page. The console's code page defaults initially to the
system's OEM code page. To change the console's code page, use the SetConsoleCP or
SetConsoleOutputCP functions, or use the chcp or mode con cp select= commands.
Requirements
Windows NT/2000 or later: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Wincon.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
y-soft©
(03.03.02 08:24)
MSDN,
Q124103, Рекомендации Microsoft:
1.Получить текущий заголовок окна (GetConsoleTitle)
2.Заменить уникальной строкой (SetConsoleTitle)
3.Sleep(40)
4.Найти окно и получить его Handle (FindWindow)
5.Восстановить первоначальный заголовок
6.Sleep(40)
7.Получить текст заголовка по найденному Handle, чтобы убедиться,
что найдено именно то окно (GetWindowText)
|