改编了一个网上找来的汇编源码
; Author: Deuce
; Enables all child windows belonging to the foreground window.
.386
.model flat,stdcall
option casemap:none
include /masm32/include/windows.inc
include /masm32/include/kernel32.inc
include /masm32/include/user32.inc
includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/user32.lib
DlgProc proto :DWORD,:DWORD,:DWORD,:DWORD
EnableAll proto :DWORD, :DWORD
.const
ENABLER equ 101
ICON equ 102
IDC_HANDLE equ 1002
IDC_ENABLE equ 1001
TIMERID equ WM_USER
.data
template db '%lX',0
posBuffer db 10 dup (0)
.code
start:
invoke GetModuleHandle,NULL
invoke DialogBoxParam,eax,ENABLER,NULL,offset DlgProc,NULL
invoke ExitProcess,eax
DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
cmp uMsg,WM_TIMER ;It's been 200 ms, enumerate the windows again!
je getPoint
cmp uMsg,WM_INITDIALOG ;Initialization stuff
je boxStart
cmp uMsg,WM_CLOSE
je boxClose
retFalse:
mov eax,FALSE
ret
boxStart:
invoke SetTimer,hWnd,TIMERID,200,NULL ;Start up the timer for 200 ms intervals
jmp retTrue
boxClose:
invoke KillTimer,hWnd,TIMERID ;Okay we're done so shut everything down
invoke EndDialog,hWnd,NULL
jmp retTrue
getPoint:
invoke IsDlgButtonChecked,hWnd,IDC_ENABLE ;Are we activated?
cmp eax,BST_CHECKED
jne retTrue
invoke GetForegroundWindow ;Yep, what window is activated?
push eax
invoke wsprintf,offset posBuffer,offset template,eax ;Translate handle value to ASCII
invoke SetDlgItemText,hWnd,IDC_HANDLE,offset posBuffer ;Set the handle edit box
pop eax
invoke EnumChildWindows,eax,offset EnableAll,NULL ;Now we are gonna filter through all child windows
retTrue:
mov eax,TRUE
ret
DlgProc endp
EnableAll proc hWnd:HWND,lParam:LPARAM ;Windows sends the handle of each child window here
invoke IsWindowEnabled,hWnd ;Is this child window enabled or not?
cmp eax,TRUE
je getNext
invoke EnableWindow,hWnd,TRUE ;No, it's not! So we'll enable it :)
invoke IsWindowVisible,hWnd ;is showwindow ok?
cmp eax,TRUE
je getNext
invoke ShowWindow,hWnd,TRUE
invoke EnableWindow,hWnd,TRUE
getNext:
mov eax,TRUE ;Return TRUE to get handle of next child window
ret
EnableAll endp
end start