自己动手编写devExpress组件自动安装程序

每次安装devExpress组件都特别麻烦,要逐个compile package,还要install...添加library path.安装过程中次序还不能搞错,头真的很大,我试过最快的手动安装也要20分钟.

接下来可以说怎么编写自动安装程序了

首先说一下思路

-------------------------------------------------------------------
如果手动安装,过程如下
-------------------------------------------------------------------
1.将压缩包解压到一个目录中
2.Delphi->Tools->Environment Option->Libary->Libary Path中加入所有/source的路径
3.依次编译package
XP Theme Manager
ExpressLibrary,
ExpressCommon Library,
ExpressDataController,
ExpressEditors Library 5,
 ... ...
ExpressExport Library
ExpressPageControl 2
ExpressQuantumGrid 5
 ... ...
ExpressGDI+ Library
ExpressNavBar
 ... ...

4.cx打头的package只要compile,dclcx打头的package要compile并install.

-------------------------------------------------------------------
自动安装原理
-------------------------------------------------------------------
使用命令行编译需要安装的package

dcc32 [option] [packagename]
-b 编译所有
-le bpl输出路径
-ln dcp输出路径
-u 源文件目录
-r 资源文件目录

文件名注意大小写

bpl加入注册表
[HKEY_CURRENT_USER/Software/Borland/BDS/4.0/Known Packages]

源文件目录加入注册表
[HKEY_CURRENT_USER/Software/Borland/BDS/4.0/Library]

编写reg文件

regedit.exe /s ***.reg    

有了以上的知识点,就可以开始动手写代码了

建立一个ini文件,记录path and package 信息

[App]
InstallDir=
Chk0=QuantumGrid
Chk1=Bars
Chk2=NavBar
Chk3=FlowChart
Chk4=Scheduler
Chk5=LayoutControl
Chk6=MasterView
Chk7=OrgChart
Chk8=PrintingSystem
Chk9=QuantumTreeList
Chk10=SpreadSheet
Chk11=VerticalGrid

[Folder_XPThemeManager]
Order=1
FolderName=XP Theme Manager
PkgCompile0=dxThemeD10.dpk

[Folder_Library]
Order=2
FolderName=ExpressLibrary
PkgCompile0=cxLibraryD10.dpk
PkgCompile1=dclcxLibraryD10.dpk
PkgInstall0=dclcxLibraryD10.bpl

[Folder_CommonLibrary]
Order=3
FolderName=ExpressCommon Library
PkgCompile0=dxComnD10.dpk

[Folder_DataController]
Order=4
FolderName=ExpressDataController
PkgCompile0=cxDataD10.dpk

[Folder_EditorsLibrary]
Order=5
FolderName=ExpressEditors Library 5
PkgCompile0=cxEditorsD10.dpk
PkgCompile1=cxExtEditorsD10.dpk
PkgCompile2=dclcxEditorsD10.dpk
PkgCompile3=dclcxExtEditorsD10.dpk
PkgInstall0=dclcxEditorsD10.bpl
PkgInstall1=dclcxExtEditorsD10.bpl

[Folder_ExportLibrary]
Order=6
FolderName=ExpressExport Library
PkgCompile0=cxExportD10.dpk

[Folder_GDILibrary]
Order=7
FolderName=ExpressGDI+ Library
PkgCompile0=dxGDIPlusD10.dpk

[Folder_PageControl]
Order=8
FolderName=ExpressPageControl 2
PkgCompile0=cxPageControlD10.dpk
PkgCompile1=dclcxPageControlD10.dpk
PkgInstall0=dclcxPageControlD10.bpl

[Folder_QuantumGrid]
Order=9
FolderName=ExpressQuantumGrid 5
PkgCompile0=cxGridD10.dpk
PkgCompile1=dclcxGridD10.dpk
PkgInstall0=dclcxGridD10.bpl

[Folder_Bars]
Order=10
FolderName=ExpressBars 5
PkgCompile0=dxBarD10.dpk
PkgCompile1=dcldxBarD10.dpk
PkgInstall0=dcldxBarD10.bpl

[Folder_NavBar]
Order=11
FolderName=ExpressNavBar
PkgCompile0=dxNavBarD10.dpk
PkgCompile1=dcldxNavBarD10.dpk
PkgInstall0=dcldxNavBarD10.bpl

[Folder_FlowChart]
Order=12
FolderName=ExpressFlowChart
PkgCompile0=dxFlowChartD10.dpk
PkgCompile1=dcldxFlowChartD10.dpk
PkgInstall0=dcldxFlowChartD10.bpl

[Folder_Scheduler]
Order=13
FolderName=ExpressScheduler 2
PkgCompile0=cxSchedulerD10.dpk
PkgCompile1=dclcxSchedulerD10.dpk
PkgInstall0=dclcxSchedulerD10.bpl

[Folder_LayoutControl]
Order=14
FolderName=ExpressLayout Control
PkgCompile0=dxLayoutControlD10.dpk
PkgCompile1=dcldxLayoutControlD10.dpk
PkgInstall0=dcldxLayoutControlD10.bpl

[Folder_MasterView]
Order=15
FolderName=ExpressMasterView
PkgCompile0=dxMasterViewD10.dpk
PkgCompile1=dcldxMasterViewD10.dpk
PkgInstall0=dcldxMasterViewD10.bpl

[Folder_OrgChart]
Order=16
FolderName=ExpressOrgChart
PkgCompile0=dxOrgCD10.dpk
PkgCompile1=dcldxOrgCD10.dpk
PkgInstall0=dcldxOrgCD10.bpl

[Folder_PrintingSystem]
Order=17
FolderName=ExpressPrinting System
PkgCompile0=dxPSCoreD10.dpk
PkgCompile1=dcldxPSCoreD10.dpk
PkgInstall0=dcldxPSCoreD10.bpl

[Folder_QuantumTreeList]
Order=18
FolderName=ExpressQuantumTreeList 4
PkgCompile0=cxTreeListD10.dpk
PkgCompile1=dclcxTreeListD10.dpk
PkgInstall0=dclcxTreeListD10.bpl

[Folder_SpreadSheet]
Order=19
FolderName=ExpressSpreadSheet
PkgCompile0=cxSpreadSheetD10.dpk
PkgCompile1=dclcxSpreadSheetD10.dpk
PkgInstall0=dclcxSpreadSheetD10.bpl

[Folder_VerticalGrid]
Order=20
FolderName=ExpressVerticalGrid
PkgCompile0=cxVerticalGridD10.dpk
PkgCompile1=dclcxVerticalGridD10.dpk
PkgInstall0=dclcxVerticalGridD10.bpl

[QuantumGrid]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_DataController
Folder3=Folder_EditorsLibrary
Folder4=Folder_ExportLibrary
Folder5=Folder_PageControl
Folder6=Folder_QuantumGrid

[Bars]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_CommonLibrary
Folder3=Folder_Bars

[NavBar]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_GDILibrary
Folder3=Folder_NavBar

[FlowChart]
Folder0=Folder_FlowChart

[Scheduler]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_DataController
Folder3=Folder_EditorsLibrary
Folder4=Folder_ExportLibrary
Folder5=Folder_Scheduler

[LayoutControl]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_CommonLibrary
Folder3=Folder_DataController
Folder4=Folder_EditorsLibrary
Folder5=Folder_LayoutControl

[MasterView]
Folder0=Folder_XPThemeManager
Folder1=Folder_CommonLibrary
Folder2=Folder_MasterView

[OrgChart]
Folder0=Folder_OrgChart

[PrintingSystem]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_CommonLibrary
Folder3=Folder_PrintingSystem

[QuantumTreeList]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_DataController
Folder3=Folder_EditorsLibrary
Folder4=Folder_ExportLibrary
Folder5=Folder_QuantumTreeList

[SpreadSheet]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_SpreadSheet

[VerticalGrid]
Folder0=Folder_XPThemeManager
Folder1=Folder_Library
Folder2=Folder_DataController
Folder3=Folder_EditorsLibrary
Folder4=Folder_ExportLibrary
Folder5=Folder_VerticalGrid

开始编写代码

建立一个窗口,根据ini的信息,动态创建checkbox,用来选择要安装的组件

当安装开始的时候,用程序写两个文件,*.bat,*.reg

bat文件里面的内容例如

--------------------------------------------

dcc32 -b ...... dxThemeD10.dpk

dcc32 -b ...... cxLibraryD10.dpk

....

regedit /s DevExpress.reg

----------------------------------------

reg文件里面的内容例如

----------------------------------------

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER/Software/Borland/BDS/4.0/Known Packages]

...

[HKEY_CURRENT_USER/Software/Borland/BDS/4.0/Library]

"Search Path"=...

----------------------------------------

补充:

获得my document 路径,因为默认的bpl路径为my document/Borland Studio Projects/Bpl

    Reg.RootKey:=HKEY_CURRENT_USER;
    Reg.OpenKey('Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders',False);
    PersonalDir:=Reg.ReadString('Personal');
    Reg.CloseKey;

根据选择的要安装的组件,生成bat和reg的文件后,

WinExec('cmd /c Compile.bat > Setup.log',SW_SHOW);

编译信息将写在 setup.log里面

注意:在程序运行前需将delphi 关闭

  • 0
    点赞
  • 0
    收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论 1

打赏作者

ZhuJunfeng

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值