Delphi XE 程序瘦身.编译后EXE最低90KB


本文整理自网络,侵删。

 
目前网络上 XE8程序瘦身基本为XE5以前的方法,虽然该方法也必须援用之前方法.但需要说明一下,现在release比debug瘦身效果相差无几.我的XE8单独窗体EXE文件为11056KB.瘦身后exe文件最低可以达到 90KB.

下面是方法介绍.

第一步:关闭debug infomation.

打开工程后,依次点击project--option--delphi compiler--linking 将右边Debug information改为False.

编译后Debug和Release版都为2142KB.

此处参考http://www.delphifans.com/InfoView/Article_6493.html



第二步: 关闭RTTi.

点击Project--view source.在第二行添加编译开关代码

{ 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}

编译后Debug和Release版都为1728KB.







第三步:设置运行时包.

打开工程后,依次点击project--option--Packages--Runtime Packages 勾选Link with runtime package.

编译后Debug的exe文件为90Kb,Release为1728KB





对于第三步,如不是太计较exe大小,则不是太建议.请看帮助资料.

Runtime packages are deployed with your applications. They provide functionality when a user runs the application.

To run an application that uses packages, a computer must have both the application's executable file and all the packages (.bpl files) that the application uses. The .bpl files must be on the system path for an application to use them. When you deploy an application, you must make sure that users have correct versions of any required .bpls.

这意味着当选择使用该选项的debug版时,你必须把正确的bpl文件一起放在应用程序目录或系统目录.我一个单按钮窗体程序必须拷贝2个bpl文件.

正确的bpl在\Embarcadero\Studio\16.0对应的文件夹里面找,比如我的虚拟xp,则为\Embarcadero\Studio\16.0\Bin目录

而且如果修改了某个控件源码,意味这必须重编译该控件.

相关阅读 >>

Delphi中控制扫描仪

Delphi vcl 模式下和firemonkey 模式下的字符串

Delphi sqlite 简明上手指南

Delphi sqlite incomplete input 错误

Delphi获取网卡mac地址

Delphi vclzip实现分卷压缩

Delphi 之 tpagecontrol组件

Delphi 取目录下指定文件到列表

Delphi 中字符串比较函数对比

Delphi cef4Delphi 常用设置

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...