级别: 工作组
- 注册时间:
- 2003-08-26
- 在线时间:
- 13小时
- 发帖:
- 6600
|
生成的文件8好比的………… - .386
- .model flat,stdcall
- option casemap:none
- include \masm32\include\windows.inc
- include \masm32\include\user32.inc
- includelib \masm32\lib\user32.lib
- include \masm32\include\kernel32.inc
- includelib \masm32\lib\kernel32.lib
- WinMain proto :DWORD,:DWORD,:DWORD
- .DATA
- ClassName db "SimpleWinClass",0
- AppName db "Our First Window",0
- .DATA?
- hInstance HINSTANCE ?
- .CODE
- start:
- invoke GetModuleHandle, NULL
- mov hInstance,eax
- invoke WinMain, hInstance,NULL, SW_SHOWDEFAULT
- invoke ExitProcess, eax
- WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,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,\
- CW_USEDEFAULT,\
- CW_USEDEFAULT,\
- CW_USEDEFAULT,\
- CW_USEDEFAULT,\
- 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
- .IF uMsg==WM_DESTROY
- invoke PostQuitMessage,NULL
- .ELSE
- invoke DefWindowProc,hWnd,uMsg,wParam,lParam
- ret
- .ENDIF
- xor eax,eax
- ret
- WndProc endp
- end start
汇编的,编译出来 2.50 KB (2,560 字节) - .386
- .model flat,stdcall
- option casemap:none
- include \masm32\include\windows.inc
- ;include \masm32\include\user32.inc
- ;includelib \masm32\lib\user32.lib
- include \masm32\include\kernel32.inc
- includelib \masm32\lib\kernel32.lib
- .DATA
- ;ClassName db "SimpleWinClass",0
- ;AppName db "Our First Window",0
- .DATA?
- ;hInstance HINSTANCE ?
- .CODE
- start:
- invoke ExitProcess, eax
- end start
编译出来 1.50 KB (1,536 字节) - program HelloWorld;
- {&PmType PM}
- {&Delphi+,H+}
- uses
- Windows, sysutils;
- var
- sfont : hfont;
- inst: hwnd;
- hwind,
- hwindedit1,
- hwindedit2,
- hwindlabel1,
- hwindbut1: hwnd;
- WClass : Twndclass;
- wmsg: tmsg;
- sz1,sz2,sz3 : pchar;
- i : integer;
- procedure process1;
- begin
- getwindowtext(hwindedit1, sz1, 255);
- sz2[0] := #0;
- for i := 0 to strlen(sz1) - 1 do
- sz2 := strcat(sz2, strpcopy(sz3,inttostr(ord(sz1[i])) + #32));
- setwindowtext(hwindedit2, sz2);
- end;
- Function WinProc(hwin:hwnd; wmsg:dword; wparm:wparam; lparm:lparam) : longint; stdcall; export;
- Begin
- Result := 0;
- Case wmsg of
- WM_Command:
- case loword(wparm) of
- 66 : process1;
- end;
- WM_destroy:
- postquitmessage(0);
- WM_keydown:
- if wparm = 13 then
- process1;
- Else
- Result := defwindowproc(hwin, wmsg, wparm, lparm);
- End;
- End;
- procedure Setup;
- begin
- inst := system.hinstance;
- // First we need to register a window class
- With WClass do
- Begin
- style := CS_GLOBALCLASS;
- lpfnWndProc := @winproc;
- cbclsextra:= 0;
- cbwndextra:= 0;
- hinstance:= inst;
- hicon:= 0;
- hcursor := 0;
- hbrbackground := 1 + color_BTNFACE;
- lpszMenuName := nil;
- lpszclassname :='ascii_Class'
- End;
- if registerclass(WClass) = 0 then// register and test class
- begin
- messagebox(0,'Class registration failed','Error',
- mb_iconstop or mb_ok);
- halt(0);
- end;
- hwind := createwindowex(ws_ex_clientedge, 'ascii_Class', 'ASCII 码查询器 1.0 -- Powered by MISL',
- ws_overlapped or ws_dlgframe or ws_minimizebox or ws_sysmenu or ws_visible,
- cw_usedefault, cw_usedefault, 350, 350,
- 0, 0, inst, nil);
- if hwind = 0 then
- begin
- messagebox(0,'Unable To Create Main Window','Error',
- mb_iconstop or mb_ok);
- halt(0);
- end;
- hwindlabel1 := createwindowex(0, 'static', '请输入要查询的字符:',
- ws_child or ws_visible,
- 24, 24, 200, 28,
- hwind, 0, inst, nil);
- hwindbut1 := createwindowex(0, 'button', '&F.查询',
- //ws_child or ws_visible or bs_DefPushButton,
- $50010001,
- 232, 56, 72, 28,
- hwind, 66, inst, nil);
- hwindedit1 := createwindowex(ws_ex_clientedge, 'edit', '',
- ws_child or ws_visible,
- 24, 56, 200, 28,
- hwind, 0, inst, nil);
- hwindedit2 := createwindowex(ws_ex_clientedge, 'edit', '',
- ws_child or ws_visible or es_multiline or es_AutoVScroll or es_ReadOnly,
- 24, 88, 200, 150,
- hwind, 0, inst, nil);
- sendmessage(hwindlabel1, WM_SETFONT, sfont, 0);
- sendmessage(hwindedit1, WM_SETFONT, sfont, 0);
- sendmessage(hwindedit2, WM_SETFONT, sfont, 0);
- sendmessage(hwindbut1, WM_SETFONT, sfont, 0);
- showwindow(hwind,sw_shownormal);
- updatewindow(hwind);
- end;
- begin
- getmem(sz1, 1024);
- getmem(sz2, 3100);
- getmem(sz3, 6);
- sfont := CreateFont(17,0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,
- CLIP_CHARACTER_PRECIS,Default_Quality,FF_DONTCARE,'Tahoma');
- Setup;
- While getmessage(wmsg,0,0,0) do
- begin
- translatemessage(wmsg);
- dispatchmessage(wmsg);
- end;
- freemem(sz1, 1024);
- freemem(sz2, 3100);
- freemem(sz3, 6);
- halt(wmsg.wparam);
- end.
用virtual pascal编译出来是 30.5 KB (31,232 字节) ………………XDXD纯净不带dll的版本哦……
|