Further,
.386. Model Flat,stdcalloptionCaseMap:noneinclude Windows.Incinclude User32.Incincludelib user32.libinclude kernel32.Incincludelib kernel32.libwinmain Proto:D Word,:D Word,:D Word,:D word;WinMain function prototype definition. Dataclassname DB"Simplewinclass",0AppName DB"My First Window",0. DATA? ;no initialized datahinstance hinstance? CommandLine LPSTR? ;string pointer variable. CODEStart:;----------------------------------------------------------------------------------------------------------- ;get the handle to the applicationInvoke Getmodulehandle,nullmovHinstance,eax;---------------------------------------------------------------------------------------------------------- -;get command line argumentsInvoke GetCommandLinemovCommandline,eax;Call the WinMain functionInvoke Winmain,hinstance,null,commandline,sw_showdefault;----------------------------------------------------------------------------------------------------------- ;exit the applicationInvoke Exitprocess,eax;----------------------------------------------------------------------------------------------------------- WinMain procHInst:HINSTANCE,Hprevinst:HINSTANCE,CmdLine:LPSTR,cmdshow:DWORD LOCALWC:wndclassex LOCALmsg:MSG LOCALhwnd:HWND;----------------------------------------------------------------------------------------------------------- ;Register window classmovwc.cbsize,sizeof wndclassexmovWc.style,cs_hredraworCs_vredrawmovWc.lpfnwndproc,offset WndProc;Specifies the window's callback functionmovWc.cbclsextra,nullmovWc.cbwndextra,nullPushhinstancePopWc.hinstance;Save instance handle for windowmovwc.hbrbackground,color_window+1 ;the background color of the windowmovWc.lpszmenuname,nullmovWc.lpszclassname,offset ClassName Invoke Loadicon,null,idi_applicationmovWc.hicon,eaxmovWc.hiconsm,eaxinvoke Loadcursor,null,idc_arrowmovwc.hcursor,eaxinvoke registerclassex,addr WC;----------------------------------------------------------------------------------------------------------- ;Creating a Window objectinvoke Createwindowex,null, ADDR ClassName, ADDR AppName, Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_usedefault, Cw_usedefault, NULL, NULL, hInst, NULLmovHwnd,eax;----------------------------------------------------------------------------------------------------------- ;Display windowInvoke Showwindow,hwnd,cmdshow;----------------------------------------------------------------------------------------------------------- ;Refresh window client areaInvoke Updatewindow,hwnd;----------------------------------------------------------------------------------------------------------- ;Enter the loop that gets the window message . While TRUE invoke Getmessage,addr Msg,null,0,0 . Break. IF (!eax) Invoke Translatemessage,addr msg invoke dispatchmessage,addr msg. ENDWmovEax,msg.wparamretWinMain ENDP;----------------------------------------------------------------------------------------------------------- ;Window callback functionWNDPROC prochWnd:HWND,umsg:UINT,WParam:WPARAM,LParam:LPARAM;Close Message-Exit processing. IF Umsg==wm_destroy invoke Postquitmessage,null. ELSE Invoke Defwindowproc,hwnd,umsg,wparam,lparamret. endifXOREax,eaxretWndProc ENDP End Start
Window programs under Windows