delphi 2010编译exe文件大小

一、体积测试、比较

 环境: delphi2010 +  vclskin5.4 + dev5.0

  1、delphi2010 单窗口

           796KB

  2、delphi2010 单窗口 + button + text

           820KB

  3、delphi2010 单窗口 + vclskin                                                                        

          1.13MB(不加载skin文件),    1.16(加载skin文件)

 

  4、delphi2010 +  vclskin5.4 + dev5.0( cXbutton + cXtext)

          1.8MB

  5、delphi2010 +  vclskin5.4 + dev5.0( cXbutton + cXtext + cxGrid)

          4.18MB   ------

 

   6、delphi2010 +  vclskin5.4 + dev5.0( cXbutton + cXtext + cxGrid )   +fastReport

           5.67M  to   6.67MB

 

二、原因

 1、delphi2010使用的wideString和RTTI

    wideString使字符串长度变成了原来的2倍,但增长体积是有限的

    RTTI是主要原因

 

2、dev

    a、使用了skin

         5.0版本当使用了QtGrid,会自动引入cxLookAndFeels, cxLookAndFeelPainters

         有时候将unit中skin都去掉效果不大,可以重新安装dev,安装时候不选skin,可以省下2M

    b、使用了print

        5M to   9M

         

 

三、减小delphi体积的方法

 1、关闭RTTI反射机制

    自从Delphi2010中引入了新的RTTI反射机制后,编译出来的程序会变得很大,这是因为默认情况下 Delphi2010 给所有类都加上了反射机制。而我们的工程并不每每都需要使用到这个功能,所以对于不需要使用的地方,我们可以简单的用下面的方法禁用RTTI反射,从而大大减小文件体积。

    禁用的方法很简单,就是要在工程(dpr文件中。Delphi2010下项目文件是dproj文件,但dpr文件仍然是默认的编写代码的项目文件)的Uses语句前添加下面的定义就可以了:

    { Reduce EXE size by disabling as much of RTTI as possible (delphi 2009/2010) }
    {$IF CompilerVersion >= 21.0}
    {$WEAKLINKRTTI ON}
    {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
    {$IFEND}

 

         -------------实测,1.1环境下,文件大小为750KB;

                                  1.2环境下,774KB;

                                  1.3环境下,大小为1.10MB(加载skin文件)

   英文:http://www.zipplet.co.uk/index.php/content/articles_programming_delphi2010rtti

2、关闭debug信息 (默认已关闭)

   Project -> Options -> Linking -> Debug information -> disabled

 测试:

   disabled:11.6MB

   an  disabled:31.2MB

 

 

 

 

四、其它方法

1、减小DELPHI应用程序的大小

        http://hi.baidu.com/51elv/blog/item/5637a5cff0ef1431f8dc6124.html

 01) 使用加壳工具(如 UPX,ASPack 等)
 02) 使用 KOL
 03) 不使用VCL来编写程序
 04) 使用 ACL (API 控制库)
 05) 使用 StripReloc
 06) 去除运程调试信息与 TD32
 07) 把允许的代码写到 DLL 中
 08) 不要在设计时把图片放置在 Form 上,而是运行时加载
 09) 使用被压缩的图片(使用JPG 而不用 BMP)
 10) 在 DFM 文件中减少属性
      (参考后面的链接 “怎样使您的EXE文件更轻便”)
 11) Use the TStringList replacement by ~LOM~
         Use the Minireg - TRegistry replacement by Ben Hochstrasser

 

 

五、其他文章

dev编译exe

http://www.devexpress.com/Support/Center/p/Q243794.aspx?searchtext=cxLookAndFeels&p=T1|P0|0

 

Delphi VCLSkin 3.81 官方试用版-HistoryNews in 3.81 11/29/2005*Support TMediaPlayer control.News in 3.80 11/20/2005*Fix some skin files.*Fix bug on ImageEn SaveImageEnDialog.News in 3.72 11/10/2005*Fix bug in TScrollbar when its min is negative.*Fix bug in Tmainmenu.News in 3.71 11/5/2005*change caption text color to gray when checkbox or radiobutton is disable.*Fix paint problem in Tbitbtn when caption is empty.*Fix bug of changing skin file when Skindata.SkinFormtype = sfOnlyThisForm.News in 3.70 10/27/2005*Support TAdvPageControl.*Support TRzMenuButton, TcxButton with cxbkDropDownButton.*work with RECREATEWND message for skined control has scrollbar.*Fix a memory leak bug.*Fix paint bug for TPagecontrol in win95.News in 3.65 10/21/2005*Add TSkindata.Options.xoMDIChildBorder which do not skin MDIChild form's border.News in 3.64 10/19/2005*Fix problem when skindata.skincontrols.xcMainMenu is flase.News in 3.63 10/15/2005*Support THeaderControl.News in 3.62 10/13/2005*fix bug in SystemMenu.News in 3.61 10/11/2005*fix bug in TcxDbCheckbox.*fix paint problem in Tcheckbox when Alignment is taLeftJustify.News in 3.60 10/10/2005*Vclskin can run in Win95.News in 3.52 10/6/2005*Fix paint problem of form border.News in 3.51 10/4/2005*Fix paint problem in checkbox with big image.News in 3.50 9/25/2005*Support Mouse Hover in Scrollbar.*Add Mouse thumb gripper in Scrollbar.News in 3.41*Fix some problem in Button when mouse move.News in 3.40 2005.9.21*Support Hover state in Header control.*Improve on TrackBar*Fix problem to unskin radiogroup.News in 3.38 2005.9.13*Fix icon problme in MDIChild.News in 3.37 2005.9.12*Fix font color problem in TButton when button is focused.News in 3.36 2005.9.9*Fix font color problem in Tgroupbox,radiobutton,checkbox.News in 3.35 2005.9.5*Support TGroupbox font color.News in 3.34 2005.8.31*Fix paint problem in Trackbar when skin file change.News in 3.33 2005.8.29*Fix problem in TcxDBCheckbox.News in 3.32 2005.8.25*Add close button on TPageControl.News in 3.31*fix problem when righ click form caption that BorderIcons:=[]News in 3.30*fix problem that show normal window border when windows first show.*fix resize problem when form border is bsSingle.News in 3.29*System menu is NOT only English.It support Language in windows.*Fix some problem in DLL applicaton.News in 3.28* fix paint bug in checkbox and radiobutton in windows common dialog.News in 3.27*fix bug in TTntDateTimePicker.*fix paint problem in TPageControl.News in 3.26*Support Popupmenu in TFrame.News in 3.25* fix Icon problem in MDIChild form.* fix caption paint problem in MDIForm.News in 3.24* Fix Icon problem in MDIChild form.* fix paint problem in Tbitbtn.* Add feature that Skin file Preview image saved in skin-builder.* Add xcTrackbar and xcSpin.News in 3.23* Support wordwrap in Bitbtn and speedbutton.* Fix scrollbar problem in TImageScrollBox.News in 3.22* fix transparent problem in button.News in 3.21* Fix paint problem in TSpidEdit.* Support owner-MeasureItem event in Popupmenu.News in 3.20* support toolbar background.* support workwrap in checkbox and radiobutton.News in 3.14*fix mainmenu merge problem .*fix flicker problem in transparent background .News in 3.13*fix scrollbar problem when form move.*fix bug in DLL form.*fix Edit control focus problem in MDIChild.*fix formresize problem when skin file change.News in 3.12* Add Focus border on checkbox,radiobutton,button.* Support Transparent Background on Checkbox,Radiobutton,Groupbox.* Support WS_EX_APPWINDOW style.* fix MDIchild problem in TBX.* improve on RzRadiobutton.News in 3.11*Support runtime package.*support ALT,ALT-Space.*support hint for scrollbar control*fix Z-order problem when skin change.*fix shortcut problem.News in 3.10*Support TBX.*Support TNT MDIChild Form.*Support more FastReprt button control.News in 3.08*Fix problem in TOpenImageEnDialog.*Paint Border in scrollbar control.*Fix checkbox paint problem in Dibiright*Fix Tscrollbox problem.*Support LMD Elpack.*Fix problem that Control without parent.*Fix bug in skin file change.News in 3.07*Fix problem when BiDiRight Mainmenu popup. *Fix bug in 3.06,3.05 when skin remove at runtime. News in 3.06*Fix bug in C++Builder.*Fix bug in scrollbar resize.*Fix bug in Delphi7 XPmanifest component.News in 3.05*Fix bug when move controls in different forms.*Fix problem in TStatusbar that is simple and DiBiRight.News in 3.04*Fix Tscrollbox problem in delphi5.*Fix Mainmenu display problem in BIDIRight.*Fix font color problem in TSpeedbutton when it is disable.*Fix bug in TntCombobox.*Fix skinfile mxskin59.skn when form is maximized.News in 3.03*Fix bug in dockable form.*Support Tbutton onMouseDown event.News in 3.02*Fix Combobx problem in BIDIRight.*Fix MOUSE WHEEL problem in Tlistbox.*Fix Scrollbar problem when control is invisible.News in 3.01*Fix problem in Inherited-MDIchild.News in 3.0*Scrollbar flicker problem fixed.*Redundant separator bars in menu are automatically removed.*Add xoMDIScrollbar to show scrollbar in MDIClient area.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值