Delphi XE8 程序瘦身.編譯後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目錄

而且如果修改了某個控件源碼,意味這必須重編譯該控件. 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章