delphi 程式發布問題

來源:互聯網
上載者:User
http://topic.csdn.net/t/20030102/15/1320762.html

Delphi具有強大的資料庫應用程式開發功能,其Client/Sever版本可以開發一般的單機資料庫應用系統、普通Client/Sever應用系 統直至基於Web的多層應用,其中自然離不開Borland資料庫引擎(BDE)的功勞。不過在沒有安裝過Delphi程式的電腦上運行資料庫程式時, 必須同時分發龐大的BDE檔案,Borland建議使用者用Delphi附帶的InstallShield製作安裝程式來解決這些問題。但怎樣選擇BDE文 件才能使自己的安裝程式更加精鍊呢?我首先介紹一下其中幾個必須的檔案:  
    Idapi32.dll:BDE基本函數庫  
    Blw32.dll:語言驅動函數庫  
    Idr20009.dll:錯誤資訊庫  
    Fareast.bll:遠東語言驅動程式  
    Usa.bll:美國語言驅動程式  
    以下檔案為根據需要可選:  
    如用Paradox,則應選擇:Idpdx32.dll  
    如用Dbase,則應選擇:Iddbas32.dll  
    如用Access,則應選擇:Iddao32.dll  
    如用Ascii,則應選擇:Idasci32.dll  
    如用TBatchMove,則應選擇:Idbat32.dll  
    如用Data   Repostitory,則應選擇:Iddr32.dll  
    如用ODBC,則應選擇:Idodbc32.dll  
    如用BDE   DataSet   Provider   DLL,則應選擇:Idprov32.dll  
    如用SQL查詢,則應選擇:Idsql32.dll  
    下面我們就以用InstallShield來製作一個Paradox資料庫應用系統的安裝程式為例:  
    1.啟動程式設定有關檔案目錄路徑,進入Setup   Checklist;  
    2.在Set   the   Visual   Design中設定程式名、程式目錄、安裝程式主視窗等;  
    3.在Specify   Components   and   Files中設定Groups   and   Files項,在Program   Files中加入使用者的所有程式檔案和資料庫表檔案,以及下列檔案:Idbat32.dll、Usa.btl、Idapi.cfg、 Charset.cvb、Bantam.dll、BLW32.dll、Idapi32.dll、Fareast.btl、Idpdx32.dll、 Idr20009.dll、Idsql32.dll(以上檔案必須含目錄路徑);  
    4.在Dialog   Boxes中設定所需安裝對話方塊;  
    5.在Make   Registry   Changes中設定Keys項,在HKEY_LOCAL_MACHINE中加入software/borland/blw32和software/ borland/database   engine兩項,並且在blw32值中加入  
    “Blapipath   ‘以上檔案目錄’”、“LOCALE_LIB0   ‘以上檔案目錄’/Fareast.bll”和“LOCALE_LIB1   ‘以上檔案目錄’/Usa.bll”,在database   engine值中加入“Dllpath   ‘以上檔案目錄’”、“Configfile01   ‘以上檔案目錄’/Idapi.cfg”;  
    6.在Specify   Folder   and   Icons中根據實際要求設定有關項目;  
    7.在Run   Disk   Builder中設定安裝盤的有關資訊;  
    8.最後進行Test   the   Installation和Create   Distribution   Media即可完成安裝程式的製作。  
  (新疆 宗宏斌)

http://community.csdn.net/Expert/TopicView3.asp?id=5290629

Delphi程式員都知道,在資料庫應用程式開發完成後,要發布程式需要同時發布BDE(Borland Database Engine),否則會引起錯誤“A Error occurred while at temping to initilize Borland Database Engine(Error $2109)”。當覺得程式太大而辛辛苦苦精簡自己的程式到滿意時,卻發現BDE管理程式器需要9M之巨,不由感到沮喪,真有點自己的努力被糟蹋的感覺。 不過也不必太沮喪,只要肯嘗試,還是有辦法來精簡BDE的。

  首先來看看BDE目錄中的檔案,所有檔案確實有近9M大吧。不過有些可能是用不到的, 關鍵檔案的作用可參見Bde32.HLP中“Introduction to Borland Data base Engine”下的“Core BDE Files”,其中列出了BDE的關鍵檔案及其作用,可以以此作為依據來嘗試精簡BDE驅動程式。下面是各個檔案的作用:

 一、不可缺少的檔案
  Blw32.dll:語言驅動函數庫。
  Idapi32.dll:BDE基本函數庫。
  Fareast.bll、Usa.bll:遠東語言及美國語言驅動程式,對中文軟體不可缺少。
  Idr20009.dll:錯誤資訊庫。

 二、資料庫驅動程式(根據需要選擇一個或多個)
  Idasci32.dll:Ascii文本資料庫驅動程式函數庫,如果不用Ascii文本資料庫,可以不要。
  Iddao32.dll:Access資料庫驅動程式函數庫,如果不用Access資料庫,可以不要。
  Iddbas32.dll:dBase資料庫驅動程式函數庫,如果不用dBase資料庫,可以不要。
  Idodbc32.dll:ODBC資料庫驅動程式函數庫,如果不用ODBC資料庫,可以不要。
  Idpdx32.dll:Paradox資料庫驅動程式函數庫,如果不用Paradox資料庫,可以不要。

 三、其它驅動程式和設定檔(根據需要選擇一個或多個)
  Idbat32.dll:批操作驅動程式函數庫,如果不用TBatchMove控制項或DbiBatchMove類函數,可以不要。
  Iddr32.dll:Data Repository驅動程式函數庫,如果不用Data Repository功能,可以不要。
  Idprov32.dll:BDE DataSet provide驅動程式函數庫,如果不用TProvider控制項,可以不要。
  Idqbe32.dll:QBE驅動程式函數庫,如果不用Query By Example,可以不要。
  Idsql32.dll:SQL查詢驅動程式函數庫,如果不用TQuery進行查詢,可以不要。
  Idapi32.cfg:BDE設定檔,如程式中沒特殊要求,可不要。也可在BDE管理器中設定正確後再分發。

 四、其它檔案(一般不用)
  BDE32.HLP、BDE32.CNT:BDE協助檔案,可以不要。
  BdeAdmin.exe、BdeAdmin.HLP、BdeAdmin.CNT:BDE管理器及協助檔案,如果不會發生要求軟體使用者自己配置BDE的情況時,可以不要。
  其它*.BLL:其它國家和地區的語言驅動程式,可以不要。
  DataBump.EXE、DataBump.HLP、DataBump.CNT:資料庫資料轉移工具及協助檔案,可以不要。
  Localsql.HLP、Localsql.CNT:SQL查詢語句協助檔案,可以不要。
  Sqllnk32.HLP、Sqllnk32.CNT:SQL串連協助檔案,可以不要。

  在根據需要選擇檔案後,還要寫註冊表檔案。這個應該不成問題,可以手工設定,但最好在程式中設定,在發現註冊表中沒有相應索引值時寫入,用TRegFile對象用不了幾行代碼的。需要設定的註冊表索引值有(在調用資料庫操作前需要有正確的索引值存在):
  資料驅動程式所在目錄的設定:
    HKEY_LOCAL_MACHINE/Software/Borland/Database Engine/DLLPATH(字串值)
  語言驅動程式所在目錄的設定:
    HKEY_LOCAL_MACHINE/Software/Borland/BLW32/BLAPIPATH(字串值)
 語言驅動程式檔案名稱:HKEY_LOCAL_MACHINE/Software/Borland/BLW32/LOCALE_LIB#(字串值)
      其中#為編號,按順序為0、1、2、3......如:
      HKEY_LOCAL_MACHINE/Software/Borland/BLW32/LOCALE_LIB0="fareasst.bll"
      HKEY_LOCAL_MACHINE/Software/Borland/BLW32/LOCALE_LIB1="usa.bll"

  就這些了,按此辦法即可有效減少BDE驅動程式的大小,例如只用TTable控制項操作Paradox資料庫,則只要Idapi32.dll、 Blw32.dll、Idr20009.dll、Fareast.bll、Usa.bll、Idpdx32.dll六個檔案即可。
這些檔案可放在任何一個目錄,只要在註冊表指明即可。OK,BDE由9M多減到不到2M,ZIP一下就700多K了,比原來的應用系統減少了不少吧。

http://delphi.about.com/od/database/l/aa021502a.htm

Deploying Delphi ADO database applications
It is time to make your Delphi ADO database application available for others to run. Once you have created a Delphi ADO based solution, the final step is to successfully deploy it to the user's computer.









 More of this Feature
Printer friendly version
 Join the Discussion
"Post your views and comments to this chapter of the free Delphi database Programming Course"
Discuss!
 Related Resources
• free DB Course.TOC
• more Database articles
• Top installation tools
 Elsewhere on the Web
• MDAC download
• DCOM download

Once you have created a Delphi ADO based solution, the final step is to successfully deploy it to the user's computer. This is the topic will cover in this chapter of the free Delphi ADO database course.

What is required by a given application varies, depending on the type of application. Each project may contain several executable files, and a number of supporting files, such as DLLs, and package files. In most cases you'll only have one executable to install on a target computer - your application's executable file - Delphi produces applications wrapped in compact exe files, so called standalone Windows application.

Applications that access databases involve special installation considerations beyond copying the application’s executable file onto the target computer.

When deploying database applications that use ADO, you need to be sure that MDAC version 2.1 or later is installed on the system where you plan to run the application. MDAC is automatically installed with software such as Windows 98 / 2000 and Internet Explorer version 5 or later. No other deployment steps are required.

ADO on Windows 95
If your client's computer has Windows 95 you may get a warning indicating that you need DCOM95 to install MDAC, since there is no support for ADO in Windows 95. Once you install DCOM95, you'll can proceed and install MDAC. Here's a tip how to find the OS version.

MS Data Version Checker
One of the tools that might be handy is the Microsoft's Component Checker. The Component Checker tool is designed to help you determine installed version information and diagnose installation issues with the Microsoft Data Access Components (MDAC).

The database file
The data files (in our case an MS Access database), must be made available to the application. You make it available by simply copying (an "empty") the MDB file to the client computer. The process must be done before the user first start the application. Each time you send an updated exe file, if the structure of the database has not changed, you do not need to redeploy the MDB file.

The connection string
Obviously, when creating database applications that are to be run on various machines, the connection to the data source should not be hard-coded in the executable. In other words, the database file may be located anywhere on the user's computer - the connection string used in the TADOConnection object must be created at run time. One of the suggested places to store the path to the database is the Windows Registry. In general to create a connection string at run time you have to a) place the Full Path to the database in Registry; and b) each time you start your application, read the Registry, "create" the ConnectionString and Open the ADOConnection. Here's a sample code.

Is that all? This seams to easy
Yes, when described by words it seems very easy, just copy the exe file, the mdb file and be sure the client computer has MDAC. Of course, the first time you try to deploy your state-of-the-art database solution you'll bump into a wall. How to copy a file on another computer to a folder like '/Program Files/YOUR COMPANY/PROJECT NAME/ApplicationName.exe'? There is an answer that might solve most of the problems, the installation tools. The Install Sheild Express that comes with some Delphi versions can be used to create an installation application. This tool gives your users the ability to select where to install your application, let's the user decide what parts of the application would be installed (exe, help, mdb, ...) and makes the process of creating a Project group in the Start menu easy. Creating insulation applications with IE Express is not hard nor is it trivial. I'll leave this for some future article.

   To the next chapter
If you need any kind of help at this point, please post to the Delphi Programming Forum where all the questions are answered and beginners are treated as experts.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.