獲得MessageBox的視窗控制代碼和其所屬的視窗類
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
includelib kernel32.lib
includelib user32.lib
.data
szDstBuffer db 128 dup (?)
szBuffer db 128 dup (?)
idTimer dd ?
hWnd dd ?
.const
szText db "你好",0
szCaption db "hello",0
szTitle db "hello",0
szFormat db "%08x,%s",0
.code
_TimerProc proc _hWnd,_uMsg,_idEvent,_dwtime
invoke FindWindow,NULL,addr szTitle
mov hWnd,eax
invoke GetClassName,eax,addr szBuffer,sizeof szBuffer
invoke wsprintf,addr szDstBuffer,addr szFormat,addr szBuffer,addr szBuffer
invoke KillTimer,NULL,idTimer
invoke MessageBox,NULL,addr szDstBuffer,NULL,MB_OK
ret
_TimerProc endp
start:
invoke SetTimer,NULL,NULL,300,addr _TimerProc
mov idTimer,eax
invoke MessageBox,NULL,addr szText,addr szCaption,MB_OK
invoke ExitProcess,NULL
end start
從外觀上容易看出MessageBox也應該是一個視窗,不過它很特殊使得我們不瞭解它,一個函式就完成了這個視窗的建立,當我們想對它進行操作時,獲得它的hWnd就成為必須做的事了-----