iczelion tut15[2]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

winmain proto :dword,:dword,:dword,:dword
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.const
idm_create_thread equ 1
idm_exit equ 2
wm_finish equ wm_user+100h

.data
classname db "win32asmthreadclass",0
appname  db "win32 asm multithreading example",0
menuname db "firstmenu",0
successstring db "the calculation is completed!",0

.data?
hinstance hinstance ?
commandline lpstr ?
hwnd handle ?
threadid dword ?

.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
    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  hinst
    pop   wc.hinstance
    mov   wc.hbrbackground,color_window+1
    mov   wc.lpszmenuname,offset menuname
    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,ws_ex_clientedge,addr classname,addr appname,\
           ws_overlappedwindow,cw_usedefault,\
           cw_usedefault,300,200,null,null,\
           hinst,null
    mov   hwnd,eax
    invoke showwindow, hwnd,sw_shownormal
    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
    .if umsg==wm_destroy
        invoke postquitmessage,null
    .elseif umsg==wm_command
        mov eax,wparam
        .if lparam==0
            .if ax==idm_create_thread
                mov  eax,offset threadproc
                invoke createthread,null,null,eax,\
                                        0,\
                                        addr threadid

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top