怎么能够让Delphi6编译出来的代码最小。。。。。 我的程序只有一个窗口,编译出来有300多K。请问高手我如何解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 减少imagelist里面图片的数量。没用的全部删除,另外,注释请不要删除。还有控件数量可以减少。能重用最好。 将没有用的单元从uese中去几个。 正常,你可以设置编译选项,设置成程序使用运行时刻包,这样Delphi的程序最多只有2、30KB,不过你发布程序的时候需要发布一个两点几兆的bpl,你自己选你要哪种吧,还有就是你可以使用ASPack之类的EXE压缩软件压缩一下你的可执行程序,这样可能可以压缩到180KB到230KB左右,现在硬盘这么便宜了,你还在乎几百KB? 编译完后用PECOMPACT工具压缩之便可. 全部改用API吧。不要用Forms单元了 设置project options的 directories output directories unit output directories 重新指定路径,这样你的代码就会小了呀 我这有一最小的带窗口和程序,看看吧!我编译出来是18KBprogram testwindow;uses Windows, Messages;var WinClass: TWndClassA; Inst, Handle, Button1, Label1, Edit1: Integer; Msg: TMsg; hFont: Integer;{ Checks if typed password is 'Amigreen' and shows Message }procedure CheckPassword;var Textlength: Integer; Text: PChar;begin TextLength := GetWindowTextLength(Edit1); if TextLength = 8 then begin GetMem(Text, TextLength + 1); GetWindowText(Edit1, Text, TextLength + 1); if Text = 'Amigreen' then begin MessageBoxA(Handle, 'Password is correct.', 'Password check', MB_OK); FreeMem(Text, TextLength + 1); Exit; end; end; MessageBoxA(Handle, 'Password is incorrect.', 'Password check', MB_OK);end;{ Custom WindowProc function }function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;begin Result := DefWindowProc(hWnd, uMsg, wParam, lParam); { Checks for messages } if (lParam = Button1) and (uMsg = WM_COMMAND) then CheckPassword; if uMsg = WM_DESTROY then Halt;end;begin { ** Register Custom WndClass ** } Inst := hInstance; with WinClass do begin style := CS_CLASSDC or CS_PARENTDC; lpfnWndProc := @WindowProc; hInstance := Inst; hbrBackground := color_btnface + 1; lpszClassname := 'AG_TESTWINDOW'; hCursor := LoadCursor(0, IDC_ARROW); end; { with } RegisterClass(WinClass); { ** Create Main Window ** } Handle := CreateWindowEx(WS_EX_WINDOWEDGE, 'AG_TESTWINDOW', 'Amigreen TestWindow 1.00', WS_VISIBLE or WS_SIZEBOX or WS_CAPTION or WS_SYSMENU, 363, 278, 305, 65, 0, 0, Inst, nil); { ** Create a button ** } Button1 := CreateWindow('Button', 'OK', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT, 216, 8, 75, 25, handle, 0, Inst, nil); { ** Create a label (static) ** } Label1 := Createwindow('Static', '', WS_VISIBLE or WS_CHILD or SS_LEFT, 8, 12, 76, 13, Handle, 0, Inst, nil); { ** Create an edit field ** } Edit1 := CreateWindowEx(WS_EX_CLIENTEDGE, 'Edit', '', WS_CHILD or WS_VISIBLE or WS_BORDER or ES_PASSWORD, 88, 8, 121, 21, Handle, 0, Inst, nil); { ** Create Font Handle ** } hFont := CreateFont(-11, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH or FF_DONTCARE, 'MS Sans Serif'); { Change fonts } if hFont <> 0 then begin SendMessage(Button1, WM_SETFONT, hFont, 0); SendMessage(Label1, WM_SETFONT, hFont, 0); SendMessage(Edit1, WM_SETFONT, hFont, 0); end; { Change label (static) text } SetWindowText(Label1, 'Enter password:'); { Set the focus to the edit control } SetFocus(Edit1); UpdateWindow(Handle); { ** Message Loop ** } while(GetMessage(Msg,Handle, 0, 0)) do begin TranslateMessage(msg); DispatchMessage(msg); end; { with }end. 编译完成之后用UPX压缩一下吧 老问题透明listview 问个简单问题,怎么汉字变成问号了? DBGRIDEH表格功能非常强大,但不知如何用等于白费,求助! 取VCLSkin的颜色变量在程序中调用? 請教各位交叉表的問題,感謝!!! IP数据包里面,如何解析HTTP协议的协议头内容,高分求解!!在线等待 HTMLHELP 中图片不能显示? 对时间字段进行查询,用filter和where有差别吗? 怎样删除一个含有文件与子文件的文件夹。 呵呵。。。一个查看窗口信息的东西,比SPY++小巧 贴一个病毒源代码,天天搞搞数据库,你们烦不烦?我最讨厌DataBase!打到DataBase!! 怪问题!
project options的 directories output directories
unit output directories 重新指定路径,这样你的代码就会小了呀
program testwindow;uses
Windows,
Messages;var
WinClass: TWndClassA;
Inst, Handle, Button1, Label1, Edit1: Integer;
Msg: TMsg;
hFont: Integer;{ Checks if typed password is 'Amigreen' and shows Message }
procedure CheckPassword;
var
Textlength: Integer;
Text: PChar;
begin
TextLength := GetWindowTextLength(Edit1);
if TextLength = 8 then
begin
GetMem(Text, TextLength + 1);
GetWindowText(Edit1, Text, TextLength + 1);
if Text = 'Amigreen' then
begin
MessageBoxA(Handle, 'Password is correct.', 'Password check', MB_OK);
FreeMem(Text, TextLength + 1);
Exit;
end;
end;
MessageBoxA(Handle, 'Password is incorrect.', 'Password check', MB_OK);
end;{ Custom WindowProc function }
function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;
begin
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
{ Checks for messages }
if (lParam = Button1) and (uMsg = WM_COMMAND) then
CheckPassword;
if uMsg = WM_DESTROY then
Halt;
end;begin
{ ** Register Custom WndClass ** }
Inst := hInstance;
with WinClass do
begin
style := CS_CLASSDC or CS_PARENTDC;
lpfnWndProc := @WindowProc;
hInstance := Inst;
hbrBackground := color_btnface + 1;
lpszClassname := 'AG_TESTWINDOW';
hCursor := LoadCursor(0, IDC_ARROW);
end; { with }
RegisterClass(WinClass); { ** Create Main Window ** }
Handle := CreateWindowEx(WS_EX_WINDOWEDGE, 'AG_TESTWINDOW', 'Amigreen TestWindow 1.00',
WS_VISIBLE or WS_SIZEBOX or WS_CAPTION or WS_SYSMENU,
363, 278, 305, 65, 0, 0, Inst, nil);
{ ** Create a button ** }
Button1 := CreateWindow('Button', 'OK', WS_VISIBLE or WS_CHILD or BS_PUSHLIKE or BS_TEXT,
216, 8, 75, 25, handle, 0, Inst, nil);
{ ** Create a label (static) ** }
Label1 := Createwindow('Static', '', WS_VISIBLE or WS_CHILD or SS_LEFT,
8, 12, 76, 13, Handle, 0, Inst, nil); { ** Create an edit field ** }
Edit1 := CreateWindowEx(WS_EX_CLIENTEDGE, 'Edit', '', WS_CHILD or WS_VISIBLE or
WS_BORDER or ES_PASSWORD, 88, 8, 121, 21, Handle, 0, Inst, nil); { ** Create Font Handle ** }
hFont := CreateFont(-11, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH or FF_DONTCARE, 'MS Sans Serif'); { Change fonts }
if hFont <> 0 then
begin
SendMessage(Button1, WM_SETFONT, hFont, 0);
SendMessage(Label1, WM_SETFONT, hFont, 0);
SendMessage(Edit1, WM_SETFONT, hFont, 0);
end;
{ Change label (static) text }
SetWindowText(Label1, 'Enter password:');
{ Set the focus to the edit control }
SetFocus(Edit1); UpdateWindow(Handle); { ** Message Loop ** }
while(GetMessage(Msg,Handle, 0, 0)) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end; { with }
end.