; 导入文件和导入库文件下个masm32就有了
; 黑色珊瑚
; 2008-06-01
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
WinMain proto :DWORD, :DWORD, :DWORD, :DWORD
.data
ClassName db "SimpleWinClass",0
AppName db "The First Window",0
OurText db "欢迎来到 Win32 汇编!",0
char WPARAM 20h
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:DWORD
local wc:WNDCLASSEX
local msg:MSG
local hwnd:HWND
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateWindowEx,NULL,\
addr ClassName,\
addr AppName,\
WS_OVERLAPPEDWINDOW,\
100,\ ;x
100,\ ;y
200,\ ;width
150,\ ;height
NULL,\
NULL,\
hInst,\
NULL
mov hwnd,eax
invoke ShowWindow,hwnd,CmdShow
invoke UpdateWindow,hwnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.break .if (!eax)
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
local hdc:HDC
local ps:PAINTSTRUCT
local rect:RECT
.if uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
invoke TextOut,hdc,0,0,addr char,1
invoke GetClientRect,hWnd,addr rect
invoke DrawText,hdc,addr OurText,-1,addr rect,\
DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint,hWnd,addr ps
.elseif uMsg==WM_CHAR
push wParam
pop char
invoke InvalidateRect,hWnd,NULL,TRUE
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
posted on 2008-06-01 08:32
Tsanie 阅读(1085)
评论(1) 编辑 收藏 引用 所属分类:
代码转载