Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2002.05.06;
Скачать: [xml.tar.bz2];

Вниз

хэндл консоли   Найти похожие ветки 

 
BorisMor   (2002-03-02 02:11) [0]

Запускается через процесс консольное приложение.
Как получить его хэндл. Заголовок постоянно меняется.


 
VuDZ   (2002-03-02 02:32) [1]

1. Win2k only: GetConsoleWindow()
2. win9x & win2k: GetConsoleText(), FindWindow()


 
BorisMor   (2002-03-02 08:39) [2]

А где взять описание GetConsoleWindow и GetConsoleText ?
(в win32.hlp не нашол)


 
VuDZ   (2002-03-02 15:04) [3]

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 the 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.



 
BorisMor   (2002-03-02 15:42) [4]

GetConsoleTitle - это конечно хорошо,но только у меня заголовок менятся (там выводится процент выполнения программы, которые меня и интересуют).
Так что поиск окна по заголовку наверное проблематичен.
Я раситывал получив хендл окна узнавать его заголовок.


 
VuDZ   (2002-03-02 15:57) [5]

так а в чём проблема-то? Get/Set ConsoleTitle и делает то, что надо


 
BorisMor   (2002-03-02 19:03) [6]

Если бы... :(
Пробовал.
Нечего не выходит.
Наверное из-за того что текущим приложением остается моя программа, а консоль у меня вообще SW_HIDE что бы не нервировать пользователя.


 
VuDZ   (2002-03-02 19:11) [7]

а чем ты пользовался? какой именно ф-ей?


 
BorisMor   (2002-03-02 20:02) [8]

GetConsoleTitle и пользовался. Но получал какие-то символы, но не
заголовок. В интернете нашол пример на си , но там заголовок постоянный.

Мне если честно вообще не понятно фраза
"retrieves the title bar string for the current console window"
А если пользователь перейдет например к фару. Что GetConsoleTitle будет обрабатывать его заголовок ?


 
VuDZ   (2002-03-02 21:12) [9]

Текущее для данного процесса, так как с один процессом может быть ассоциирована только одна консоль. у меня всё работаетправльно

А как ты меняешь заоловок?


 
y-soft   (2002-03-03 08:24) [10]

MSDN, Q124103, Рекомендации Microsoft:

1.Получить текущий заголовок окна (GetConsoleTitle)
2.Заменить уникальной строкой (SetConsoleTitle)
3.Sleep(40)
4.Найти окно и получить его Handle (FindWindow)
5.Восстановить первоначальный заголовок
6.Sleep(40)
7.Получить текст заголовка по найденному Handle, чтобы убедиться, что найдено именно то окно (GetWindowText)


 
Olgerd   (2002-03-03 18:29) [11]

В Microsoft одни извращенцы


 
VuDZ   (2002-03-03 21:27) [12]

по-моему можно совместить 1 и 4 шаги и всё будет отлично - я так делаю и всё работает



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2002.05.06;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.005 c
4-17742
Пастор
2002-03-02 22:33
2002.05.06
API Controls Library


3-17496
Limonad
2002-04-12 14:53
2002.05.06
Знатоки, почему по выходу из приложения программа ругается


1-17619
Turalyon
2002-04-22 14:10
2002.05.06
Сервесы


1-17552
sergey32
2002-04-24 10:22
2002.05.06
DateTimePicker глючит


4-17732
a_k_v
2002-01-22 08:36
2002.05.06
OPC + Delphi + SafeArray =???





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский