Simple window
.386 .model flat, stdcall option casemap: none include /masm32/include/windows.inc include /masm32/include/user32.inc includelib /masm32/lib/user32.lib; calls to functions in user32.lib and kernel32.lib Include /masm32/include/kernel32.incinc includelib /masm32/lib/kernel32.lib
Winmain Proto: DWORD,: DWORD,: DWORD,: DWORD
.Data; Initialized Data ClassName DB "SimpleWinclass", 0; The name of our window Class Appname DB "Our First Window", 0; The Name of Our Window
??? .DATA; Uninitialized data hInstance HINSTANCE; Instance handle of our program CommandLine LPSTR .CODE; Here begins our code start: invoke GetModuleHandle, NULL; get the instance handle of our program; Under Win32, hmodule == hinstance mov hInstance. , eax mov hInstance, eax invoke GetCommandLine;. get the command line You do not have to call this function IF; your program does not process the command line mov CommandLine, eax invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT.; Call the main function invoke EXITPROCESS, EAX; Quit Our Program. The exit code is returned in Eax from WinMain.
Winmain Proc Hinst: Hinstance, Hprevinst: Hinstance, Cmdline: lpstr, cmdshow: dword local wc: wndclassex; Create Local Variables On Stack Local MSG: MSG local hwnd: hwnd
mov wc.cbSize, SIZEOF WNDCLASSEX; fill values in members of wc 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; register our window class invoke CreateWindowEx, NULL, / aDDR ClassName, / aDDR AppName, / WS_OVERLAPPEDWINDOW, / CW_USEDEFAULT, / CW_USEDEFAULT, / CW_USEDEFAULT, / CW_USEDEFAULT, / NULL, / NULL, / hInst, / NULL mov hwnd, EAX invoke ShowWindow, hwnd, CmdShow; display our window on desktop invoke UpdateWindow, hwnd; refresh the client area.WHILE TRUE; Enter message loop invoke GetMessage, ADDR msg, NULL, 0,0 .BREAK .IF (eax!) invoke TranslateMessage, Addr Msg Invoke DispatchMess Beach
WndProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM .IF uMsg == WM_DESTROY; if the user closes our window invoke PostQuitMessage, NULL; quit our application .ELSE invoke DefWindowProc, hWnd, uMsg, wParam, lParam ; DEFAULT Message Processing Ret .endif Xor Eax, Eax Ret WndProc Endped Start
Not much to say, and the C language is too much! !
By the way, give an example of a C language: