WIN32汇编-第一个窗口程序
2013-04-23 13:12
337 查看
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.const
szClassName db 'MyWindow',0
szWinName db '第一个汇编窗口',0
szHello db 'Hello',0
.data?
hInstance dd ?
hWinMain dd ?
.code
_WindowProc proc uses ebx esi edi,hwnd,uMsg,wParam,lParam
LOCAL @stPaint:PAINTSTRUCT
LOCAL @stRect:RECT
LOCAL @hdc
;mov eax,uMsg
.if uMsg == WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWinMain,addr @stPaint
mov @hdc,eax
invoke GetClientRect,hWinMain,addr @stRect
invoke DrawText,@hdc,offset szHello,-1,addr @stRect,DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint,hWinMain,addr @stPaint
.else
invoke DefWindowProc,hwnd,uMsg,wParam,lParam
;ret ;这里注释掉后功能正常
.endif
;xor eax,eax ;这里注释掉后功能正常
ret
_WindowProc endp
_Main proc
LOCAL @stWndClass:WNDCLASSEX
LOCAL @stMsg:MSG
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
invoke LoadCursor,NULL,IDC_ARROW
push hInstance
pop @stWndClass.hInstance
mov @stWndClass.cbSize,sizeof @stWndClass
mov @stWndClass.style,CS_VREDRAW or CS_HREDRAW
mov @stWndClass.lpfnWndProc,offset _WindowProc
mov @stWndClass.hbrBackground,COLOR_WINDOW + 1
mov @stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr @stWndClass
invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
offset szClassName,
offset szWinName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,NULL,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr @stMsg,NULL,0,0
.break .if eax == 0
invoke TranslateMessage,addr @stMsg
invoke DispatchMessage,addr @stMsg
.endw
ret
_Main endp
start:
invoke _Main
invoke ExitProcess,NULL
end start
==========================================================================
以上程序摘自罗云彬的《Windows环境下32位汇编语言程序设计-琢石成器》
源代码通过Radasm编译运行通过
相关文章推荐
- Win32汇编——第一个窗口程序
- Win32汇编窗口程序设计[03]--第一个窗口程序
- win32汇编第一个窗口程序
- 第一个Win32汇编程序
- 第一个win32汇编程序开发步骤
- 第一个手写Win32窗口程序
- win32汇编--创建窗口程序(RadAsm)
- Jack's第一个Win32汇编程序HelloWorld
- 我的第一个Win32汇编程序 HelloWorld
- Win32汇编--开始了解窗口程序
- windows下32位汇编语言学习笔记 第四章 第一个窗口程序 (windows的消息机制)
- windows下32位汇编语言学习笔记 第四章 第一个窗口程序 1 (消息的使用和入口代码)
- Win32汇编程序——一个窗口函数
- Win32汇编语言学习笔记>>第二课:编写第一个Win32汇编程序
- 第一个Win32窗口程序,纪念自己的Windows编程之旅
- 我的第一个win32窗口程序------------记录
- MASM写的第一个Win32 窗口程序
- 利用纯汇编写一个WIN32的窗口程序
- 我的第一个win32汇编程序
- WIN32汇编下的窗口程序