发信人: notbig(老奀)
整理人: zfinch(2003-03-06 17:33:50), 站内信件
|
最近太多朋友问安装程序部分,部分是用ASA做数据库,下面给出我用INSTALLSHIELD做安装盘的脚本,供参考。
我的ASA开发时选取网络服务器,所以安装盘分为服务器版和工作站版,服务器版和工作站版都提供数据库的ODBC驱动注册ODBC,服务器版还提供数据库启动和停止的控制(因为是网络数据库,所以必须该机开机时数据库就得启动)。虽然有两个版本,但还是做成一个安装文件中,只是安装过程需要用户选择是安装工作站还是安装服务器。
下面只是提供脚本用于安装选项和注册部分(包括反注册部分),对于数据库支持文件与选择版本装与不装的控制这里不详述,用过的都知道在那做了。
主程序部分:
////////////////////////////////////////////////////////////////////////////////
//
// File Name: Setup.rul
//
// Description: InstallShield script
//
// Comments: This script was generated based on the selections you made in
// the Project Wizard. Refer to the help topic entitled "Modify
// the script that the Project Wizard generates" for information
// on possible next steps.
//
////////////////////////////////////////////////////////////////////////////////
// Include header files
#include "ifx.h"
////////////////////// string defines ////////////////////////////
//////////////////// installation declarations ///////////////////
// ----- DLL function prototypes -----
// your DLL function prototypes
// ---- script function prototypes -----
// your script function prototypes
// your global variables
string szSerialno;
number bvType;
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIBefore
//
// EVENT: FirstUIBefore event is sent when installation is run for the first
// time on given machine. In the handler installation usually displays
// UI allowing end user to specify installation parameters. After this
// function returns, ComponentTransferData is called to perform file
// transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
number nResult,nSetupType;
string szTitle, szMsg;
string szLicenseFile, szQuestion;
string szName, szCompany, szSerial;
string szTargetPath;
string szDir;
string szComponents, szTargetdir;
number nLevel;
number nvSize;
string szComponent;
number bvCheck1,bvCheck2 ;
begin
// TO DO: if you want to enable background, window title, and caption bar title
// SetTitle( @TITLE_MAIN, 24, WHITE );
// SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));
nSetupType = TYPICAL;
TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME;
szDir = TARGETDIR;
szName = "";
szCompany = "";
szSerial = "";
Dlg_Start:
// beginning of dialogs label
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;
Dlg_SdLicense:
szLicenseFile = SUPPORTDIR ^ "license.txt";
szTitle = "";
szMsg = "";
szQuestion = "";
nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdRegisterUserEx:
szMsg = "";
szTitle = "";
nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial );
if (nResult = BACK) goto Dlg_SdLicense;
CheckSerial:
StrToUpper ( szSerial , szSerial );
if ( szSerial != "98866445") then
szMsg = "序列号错误,请重新输入" ;
MessageBox ( szMsg , WARNING );
szSerial = "";
goto Dlg_SdRegisterUserEx;
endif;
szSerialno = szSerial;
SelectType:
szMsg="请选择安装的计算机器用于:" ;
bvCheck1 = TRUE;
bvCheck2 = FALSE;
bvType = TRUE;
nResult = AskOptions ( EXCLUSIVE , szMsg , "服务器" , bvCheck1 , "工作站" , bvCheck2 );
if (nResult = BACK) goto Dlg_SdRegisterUserEx;
if bvCheck2 = TRUE then
bvType = FALSE;
szComponent = "数据库"+"\\"+"数据库文件";
ComponentSelectItem ( MEDIA , szComponent , FALSE );
ComponentSetData (MEDIA, szComponent,COMPONENT_FIELD_VISIBLE , FALSE, "");
endif;
Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
if (nResult = BACK) goto SelectType;
Dlg_SetupType:
szTitle = "";
szMsg = "";
nResult = SetupType ( szTitle , szMsg , "" , nSetupType , 0 );
if (nResult = BACK) then
goto Dlg_SdAskDestPath;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nvSize = 0;
ComponentCompareSizeRequired(MEDIA,szTargetPath,nvSize);
if (nvSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType;
endif;
endif;
endif;
Dlg_SdComponentTree:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType;
szTitle = "";
szMsg = "";
szTargetdir = TARGETDIR;
szComponents = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);
if (nResult = BACK) goto Dlg_SetupType;
endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages(nResult);
if (nResult = BACK) goto Dlg_SdComponentTree;
// setup default status
SetStatusWindow(0, "");
Enable(STATUSEX);
StatusUpdate(ON, 100);
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoving
//
// EVENT: Moving event is sent when file transfer is started as a result of
// ComponentTransferData call, before any file transfer operations
// are performed.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoving()
string szAppPath;
begin
// Set LOGO Compliance Application Path
// TO DO : if your application .exe is in a subfolder of TARGETDIR then add subfolder
szAppPath = TARGETDIR;
RegDBSetItem(REGDB_APPPATH, szAppPath);
RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);
end;
// --- include script file section ---
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoved
//
// EVENT: Moved event is sent when file transfer started by ComponentTransferData call
// has finished. At this point all file transfer operations are completed
// except for batch self-registration which is performed immediately after this
// function returns. During uninstallation this event sent after uninstallation
// is completed. For that reason you should not modify system state in this
// event handler.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoved()
string szFileName,szSectionName;
string szKeyName;
string szKey, szName, szValue;
number nSize;
string szNumName,szNumValue;
number nType,nRootKey;
number nvType, nvSize;
string svNumValue;
string szTitle , szMsg;
begin
szTitle = "重新启动计算机";
szMsg = "安装完成,请重新启动计算机";
if bvType = TRUE then
RebootDialog ( szTitle , szMsg , SYS_BOOTMACHINE );
endif;
end;
#include "ComponentEvents.rul"
[email protected]
已得分:0 发表时间:2003-3-4 12:14:31 版主操作: [删除]
notbig 老奀
专家分: 3359
文 章: 2049
结贴率: 30/34
注册部分:
///////////////////////////////////////////////////////////////////////////////
// EVENT: Installed event is sent just after files for the component:
// 数据库\数据库文件 are transferred.
///////////////////////////////////////////////////////////////////////////////
export prototype Component_Installed();
function Component_Installed()
string szFileName,szSectionName;
string szKeyName;
string szKey, szName, szValue;
number nSize;
string szNumName,szNumValue;
number nType,nRootKey;
number nvType, nvSize;
string svNumValue;
string szTitle , szMsg;
begin
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE\\华普软件\\退休人员管理系统"; //^ @COMPANY_NAME ^ @PRODUCT_NAME ; //自己的主键
if bvType = TRUE then
szNumName = "dbrun";
szNumValue = "\"" + TARGETDIR^"dbsrv7.exe\" -xtcpip -z \""+TARGETDIR^"PERSONDATA.DB\"";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
endif;
szNumName = "dbstop";
szNumValue = "\"" + TARGETDIR^"dbstop.exe\" -c \"eng=persondata;uid=DBA;pwd=SQL\"";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
endif;
//注册启动数据库服务
szKey = "\\SOFTWARE" ^ "Microsoft"^"Windows"^"CurrentVersion"^"Run" ;
szNumName = "PCARDDATA";//键名
szNumValue = "\"" + TARGETDIR^"dbsrv7.exe\" -xtcpip -z \""+TARGETDIR^"PERSONDATA.DB\"";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
endif;
endif;
end;
///////////////////////////////////////////////////////////////////////////////
// EVENT: Installed event is sent just after files for the component:
// 数据库\数据库支持文件 are transferred.
///////////////////////////////////////////////////////////////////////////////
export prototype Component1_Installed();
function Component1_Installed()
string szFileName,szSectionName;
string szKeyName;
string szKey, szName, szValue;
number nSize;
string szNumName,szNumValue;
number nType,nRootKey;
number nvType, nvSize;
string svNumValue;
string szTitle , szMsg;
begin
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE\\华普软件\\退休人员管理系统"; //^ @COMPANY_NAME ^ @PRODUCT_NAME ; //自己的主键
szNumName = "SERVERtag";//键名
if bvType = TRUE then
szNumValue = "1";//键值
else
szNumValue = "0";
endif;
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
endif;
nRootKey = HKEY_CURRENT_USER ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE" ^ "ODBC"^"ODBC.INI"^"mypcard";
szNumName = "(default)";//键名
szNumValue = "";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "AutoStop";//键名
szNumValue = "yes";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "DatabaseName";//键名
szNumValue = "persondata";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "EngineName";//键名
szNumValue = "persondata";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "Commlinks";//键名
szNumValue = "TCPIP{},SharedMemory";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "DescribeCursor";//键名
szNumValue = "No";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "Driver";//键名
szNumValue = TARGETDIR ^ "DBODBC7.DLL";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "Integerated";//键名
szNumValue = "No";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE" ^ "ODBC"^"ODBCINST.INI"^"MYASA 7.0";
szNumName = "(default)";//键名
szNumValue = "";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "Driver";//键名
szNumValue = TARGETDIR ^ "DBODBC7.DLL";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "Setup";//键名
szNumValue = TARGETDIR ^ "DBODBC7.DLL";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
end;
///////////////////////////////////////////////////////////////////////////////
// EVENT: Installed event is sent just after files for the component:
// 主程序 are transferred.
///////////////////////////////////////////////////////////////////////////////
export prototype Component2_Installed();
function Component2_Installed()
string szFileName,szSectionName;
string szKeyName;
string szKey, szName, szValue;
number nSize;
string szNumName,szNumValue;
number nType,nRootKey;
number nvType, nvSize;
string svNumValue;
string szTitle , szMsg;
begin
szFileName = TARGETDIR ^ "app_data.ini";
szSectionName = "database";
szKeyName = "DBMS";
WriteProfString ( szFileName , szSectionName , szKeyName ,"ODBC" );
szKeyName = "AutoCommit";
WriteProfString ( szFileName , szSectionName , szKeyName ,"false" );
szKeyName = "DBParm";
WriteProfString ( szFileName , szSectionName , szKeyName ,"ConnectString='DSN=mypcard;UID=DBA;PWD=SQL'" );
szSectionName = "group";
szKeyName = "group_id";
WriteProfString ( szFileName , szSectionName , szKeyName ,"01" );
szSectionName = "parm";
szKeyName = "type";
WriteProfString ( szFileName , szSectionName , szKeyName ,"128" );
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE\\华普软件\\退休人员管理系统"; //^ @COMPANY_NAME ^ @PRODUCT_NAME ; //自己的主键
szNumName = "serialno";//键名
szNumValue = szSerialno;//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
szNumName = "mytag";//键名
szNumValue = "1024";//键值
nType = REGDB_STRING;//类型
nSize = -1;//指定大小
if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then
RegDBSetKeyValueEx(szKey, szNumName, nType, szNumValue,nSize) ;
endif;
end;
///////////////////////////////////////////////////////////////////////////////
// EVENT: Uninstalled event is sent just after files for the component:
// 数据库\数据库文件 are removed during uninstallation.
///////////////////////////////////////////////////////////////////////////////
export prototype Component_UnInstalled();
function Component_UnInstalled()
string szFileName,szSectionName;
string szKeyName;
string szKey, szName, szValue;
number nSize;
string szNumName,szNumValue;
number nType,nRootKey;
number nvType, nvSize;
string svNumValue;
string szTitle , szMsg;
begin
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE\\华普软件\\退休人员管理系统"; //^ @COMPANY_NAME ^ @PRODUCT_NAME ; //自己的主键
szNumName = "dbrun";
RegDBDeleteValue(szKey, szNumName) ;
szNumName = "dbstop";
RegDBDeleteValue(szKey, szNumName) ;
//启动数据库服务
szKey = "\\SOFTWARE" ^ "Microsoft"^"Windows"^"CurrentVersion"^"Run" ;
szNumName = "PCARDDATA";//键名
RegDBDeleteValue(szKey, szNumName) ;
end;
///////////////////////////////////////////////////////////////////////////////
// EVENT: Uninstalled event is sent just after files for the component:
// 主程序 are removed during uninstallation.
///////////////////////////////////////////////////////////////////////////////
export prototype Component1_UnInstalled();
function Component1_UnInstalled()
number nRootKey;
string szKey,szNumName;
begin
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE\\华普软件\\退休人员管理系统"; //^ @COMPANY_NAME ^ @PRODUCT_NAME ; //自己的主键
szNumName = "serialno";//键名
RegDBDeleteValue(szKey, szNumName) ;
end;
///////////////////////////////////////////////////////////////////////////////
// EVENT: Uninstalled event is sent just after files for the component:
// 数据库\数据库支持文件 are removed during uninstallation.
///////////////////////////////////////////////////////////////////////////////
export prototype Component2_UnInstalled();
function Component2_UnInstalled()
number nRootKey;
string szKey,szNumName;
begin
nRootKey = HKEY_LOCAL_MACHINE ;
RegDBSetDefaultRoot (nRootKey);
szKey = "\\SOFTWARE\\华普软件\\退休人员管理系统"; //^ @COMPANY_NAME ^ @PRODUCT_NAME ; //自己的主键
szNumName = "SERVERtag";
RegDBDeleteValue(szKey, szNumName) ;
end;
对于使用ASA单机版用户,可以不用注册启动和停止数据库部分,ODBC的设置也略有不同,可参照当前机的ODBC设置中的值来改。
---- [email protected]
|
|