Based on this MS article (http://support.microsoft.com/kb/124103), I coded a function to retrieve the handle of a console window :
; Reference :
; How To Obtain a Console Window Handle (HWND)
; http://support.microsoft.com/kb/124103
include GetConsHandle.inc
BUFFER_SIZE = 256
.data
TitleFormat1 db '%d-%d',0
.code
GetConsHandle PROC USES esi
LOCAL szConsTitle[BUFFER_SIZE]:BYTE
LOCAL buffer[BUFFER_SIZE]:BYTE
lea esi,[buffer]
invoke GetConsoleTitle,ADDR szConsTitle,BUFFER_SIZE
invoke GetCurrentProcessId
push eax
invoke GetTickCount
push eax
push OFFSET TitleFormat1
push esi
call wsprintf
add esp,4*4
invoke SetConsoleTitle,esi
invoke Sleep,50
invoke FindWindow,0,esi
mov esi,eax
invoke SetConsoleTitle,ADDR szConsTitle
mov eax,esi
ret
GetConsHandle ENDP
END
[attachment deleted by admin]
Windows 2000 and the successor operating systems are providing the GetConsoleWindow (http://msdn.microsoft.com/en-us/library/ms683175(VS.85).aspx) API function to obtain the console window handle.