每次安装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 关闭
联系客服