|
Posted on 2009-03-24 08:50 S.l.e!ep.¢% 閱讀(1695) 評(píng)論(0) 編輯 收藏 引用 所屬分類(lèi): InstallShield
Data Type in InstallShield?? And Win32API Data Type BOOL TRUE or FALSE CHAR 8-bit 有符號(hào)字符 DWORD 同NUMBER HWND 窗口句柄(內(nèi)部類(lèi)型是NUMBER) INT 同NUMBER LIST 指向InstallShield list的指針(內(nèi)部類(lèi)型是NUMBER) LONG 同NUMBER LPSTR 同POINTER NUMBER 有符號(hào)4字節(jié)整數(shù) POINTER 指向數(shù)據(jù)的指針(如int i;p=&i) SHORT 同NUMBER STRING 字符串 Call API? For Example prototype KERNEL32.GetVolumeInformation(BYREF STRING, BYREF STRING, NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF STRING, NUMBER);? 附加一篇不錯(cuò)的文章 - 曾經(jīng)使用installshield制作的安裝程序,包括Mysql初始化、安裝jre、配置環(huán)境變量、簡(jiǎn)單注冊(cè)碼生成。??
曾經(jīng)使用installshield制作的安裝程序,包括Mysql初始化、安裝jre、配置環(huán)境變量、簡(jiǎn)單注冊(cè)碼生成。 - ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??? ??
- #include?"ifx.h" ??
- ??? ??
- ??
- ??
- ??
- ??
- ??????
- ??
- ??
- ??
- ??????
- ??????
- ? ??
- NUMBER?volumeNum; ??
- ??
- prototype?KERNEL32.GetVolumeInformation(BYREF?STRING,?BYREF?STRING,?NUMBER,?BYREF?NUMBER,?BYREF?NUMBER,?BYREF?NUMBER,?BYREF?STRING,?NUMBER); ??
- ??
- prototype?GetVolumeSerial(); ??
- ??
- function?GetVolumeSerial() ??
- STRING?lpRootPathName; ??
- STRING?lpVolumeNameBuffer; ??
- NUMBER?nVolumeNameSize; ??
- NUMBER?lpVolumeSerialNumber; ??
- NUMBER?lpMaximumComponentLength; ??
- NUMBER?lpFileSystemFlags; ??
- STRING?lpFileSystemNameBuffer; ??
- NUMBER?nFileSystemNameSize; ??
- BOOL?APIReturn; ??
- begin ??
- ??lpRootPathName="d:\\"; ??
- ??nVolumeNameSize=60; ??
- ??nFileSystemNameSize=60; ??
- ????
- ??APIReturn=GetVolumeInformation(lpRootPathName,?lpVolumeNameBuffer,?nVolumeNameSize,???lpVolumeSerialNumber,?lpMaximumComponentLength,?lpFileSystemFlags,?lpFileSystemNameBuffer,?nFileSystemNameSize); ??
- ? ??
- ? ??
- ??if?(APIReturn)?then???????? ??
- ? ??
- ???volumeNum?=?lpVolumeSerialNumber?;? ??
- ???if?(volumeNum?<?0)?then ??
- ????volumeNum?=?0?-?volumeNum; ??
- ???endif;????? ??
- ?????
- ??????
- ???if?(volumeNum?>?2139999999?-?135792468)?then??????? ??
- ? ??
- ??????
- ????volumeNum?=?volumeNum?-?volumeNum/100000000*100000000; ??
- ???endif;????? ??
- ??? ??
- ??else???????????????????? ??
- ? ??
- ?????volumeNum?=?123456789; ??
- ??????
- ??endif; ??
- end?; ??
- prototype?getNumString(); ??
- function?getNumString() ??
- ??number?numSpace; ??
- ??number?numMen; ??
- ??string?tmpString; ??
- begin???????????????????????????????????????? ??
- ???????
- ???????
- ?????numSpace?=?GetDiskSpaceEx("c:\\",KBYTES);???
- ???????
- ?????numMen?=?GetDiskSpaceEx("d:\\",KBYTES); ??
- ?????if?numSpace?<?10000?then ??
- ????????numSpace?=?11360000; ??
- ?????else??
- ??????numSpace?=?(numSpace?-?numSpace/10000*10000)*10000; ??
- ?????endif; ??
- ?????if?numMen?<?10000?then ??
- ????????numMen?=?7521;?? ??
- ?????else??
- ??????numMen?=?numMen?-?numMen/10000*10000; ??
- ?????endif;?????????????????????????????????????????????????? ??
- ?????volumeNum?=?100000000?+?numSpace?+?numMen;? ??
- ???? ??
- ???????
- ??????
- end;?? ??
- ? ??
- ? ??
- ? ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- function?OnFirstUIBefore() ??
- ????number??nResult,nSetupType; ??
- ????string??szTitle,?szMsg; ??
- ????string??szLicenseFile,?szQuestion; ??
- ????string??szName,?szCompany,?szSerial; ??
- ????string??szFile; ??
- ????string??szTargetPath; ??
- ????string??szDir; ??
- ????string??szfolder; ??
- ????string??szComponents,?szTargetdir; ??
- ????number??nLevel; ??
- ????LIST????listStartCopy; ??
- ????LIST????list; ??
- ????number??nvSize;???? ??
- ??? ??
- ????string?szField1,?svEdit1,szField2,?svEdit2; ??
- ????????????????????? ??
- ????string?localNum;?? ??
- ????number?tmpNum;????? ??
- ????string?tmpCheckString; ??
- ????string?checkString; ??
- begin? ??
- ??????
- ??????
- ??????
- ??????
- ??????
- ??????
- ?????????? ??
- ????GetVolumeSerial();???????????????????? ??
- ??????
- ??? ??
- ????tmpNum?=??volumeNum;????????????? ??
- ????tmpNum?=?tmpNum?-?tmpNum?/?100?*?100;?? ??
- ????NumToStr(tmpCheckString,tmpNum);???? ??
- ????if?(tmpCheckString?==?"0")?then ??
- ??????tmpCheckString?=?"0X"; ??
- ????endif; ??
- ????checkString?=?"B"?+?tmpCheckString?+?"_";????? ??
- ??? ??
- ????tmpNum?=??volumeNum?/?100;????????????? ??
- ????tmpNum?=?tmpNum?-?tmpNum?/?100?*?100;?? ??
- ????NumToStr(tmpCheckString,tmpNum);??? ??
- ????if?(tmpCheckString?==?"0")?then ??
- ??????tmpCheckString?=?"0X"; ??
- ????endif; ??
- ????checkString?=?checkString?+?"K"?+?tmpCheckString?+?"_"; ??
- ??? ??
- ????tmpNum?=??volumeNum?/?10000;????????????? ??
- ????tmpNum?=?tmpNum?-?tmpNum?/?100?*?100;?? ??
- ????NumToStr(tmpCheckString,tmpNum);?? ??
- ????if?(tmpCheckString?==?"0")?then ??
- ??????tmpCheckString?=?"0X"; ??
- ????endif; ??
- ????checkString?=?checkString?+?"X"?+?tmpCheckString?+?"_"; ??
- ??? ??
- ????tmpNum?=??volumeNum?/?1000000;????????????? ??
- ????tmpNum?=?tmpNum?-?tmpNum?/?100?*?100;?? ??
- ????NumToStr(tmpCheckString,tmpNum); ??
- ????if?(tmpCheckString?==?"0")?then ??
- ??????tmpCheckString?=?"0X"; ??
- ????endif;? ??
- ????checkString?=?checkString?+?"T"?+?tmpCheckString; ??
- ??????????????????????????????????????????????????? ??
- ??????
- ?????? ??
- ??????
- ??????
- ????volumeNum?=?volumeNum?+?135792468;??????????? ??
- ????NumToStr(localNum,volumeNum);??????????????????????????????????????????????????? ??
- ??????
- ??? ??
- ???????????????????????? ??
- ??????
- ???nResult?=?XCopyFile(SRCDIR?^?"xxx\\icons\\media\\*.gif",?"c:\\xxx\\icons\\media\\",EXCLUDE_SUBDIR);????????????????????????????????????????????????????????????????????????????????????????????????? ??
- ???nResult?=?XCopyFile(SRCDIR?^?"xxx\\icons\\teacher\\*.jpg",?"c:\\xxx\\icons\\teacher\\",EXCLUDE_SUBDIR);??? ??
- ???CreateDir("c:\\xxx\\resc\\");?????????????????????? ??
- ???????? ??
- ???if?(nResult?!=?0)?then??????? ??
- ?????????MessageBox?("圖片拷貝出錯(cuò)!",?SEVERE); ??
- ???endif; ??
- ??? ??
- ??????? ??
- ??????? ??
- ??????? ??
- ??????? ??
- ?????? ??
- ?????? ??
- ?????? ??
- ????nSetupType?=?TYPICAL;? ??
- ????TARGETDIR?=?PROGRAMFILES?^@COMPANY_NAME?^@PRODUCT_NAME;? ??
- ????szDir?=?TARGETDIR; ??
- ????SHELL_OBJECT_FOLDER?=?@FOLDER_NAME; ??
- ????szName????=?""; ??
- ????szCompany?=?""; ??
- ????szSerial?=?""; ??
- Dlg_Start: ??
- ??????
- Dlg_SdWelcome: ??
- ????szTitle?=?"xxxx系統(tǒng)"; ??
- ????szMsg???=?"??確定是否繼續(xù)安裝?繼續(xù)請(qǐng)按【下一步(next)】"; ??
- ????nResult?=?SdWelcome(?szTitle,?szMsg?); ??
- ????if?(nResult?=?BACK)?goto?Dlg_Start; ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- Dlg_SdShowInfoList:????? ??
- ??????
- ??????
- ??????
- ????szTitle?=?"系統(tǒng)本地編號(hào)"; ??
- ????szMsg????=?"將下面的本地編號(hào)發(fā)送給權(quán)限授予機(jī)構(gòu),在接收到相應(yīng)的注冊(cè)碼后,您將進(jìn)行繼續(xù)注冊(cè)!";????? ??
- ????szField1?=?"編號(hào)"; ??
- ????svEdit1?=?localNum; ??
- ??????
- ??????
- ????nResult?=?SdShowDlgEdit1(szTitle,?szMsg,szField1,?svEdit1);??????? ??
- ??????
- ????if?(nResult?=?BACK)?goto?Dlg_SdWelcome; ??
- Dlg_SdRegisterUserEx: ??
- ????szMsg???=?"請(qǐng)輸入:用戶名、公司名和注冊(cè)號(hào)"; ??
- ????szTitle?=?"xxxx系統(tǒng)";?????? ??
- ????nResult?=?SdRegisterUserEx(?szTitle,?szMsg,?szName,?szCompany,?szSerial?); ??
- ????if?(nResult?=?BACK)?goto?Dlg_SdShowInfoList; ??
- ????if?(szSerial?!=?checkString)??then????? ??
- ????????MessageBox(?"注冊(cè)碼輸入錯(cuò)誤!",?SEVERE); ??
- ???????goto?Dlg_SdRegisterUserEx;???? ??
- ????endif; ??
- ?????????????????????? ??
- Dlg_SdShowDlgEdit2: ??
- ????szTitle?=?"數(shù)據(jù)庫(kù)信息"; ??
- ????szMsg????=?"請(qǐng)輸入數(shù)據(jù)庫(kù)用戶名和數(shù)據(jù)庫(kù)密碼:";?????? ??
- ????szField1?=?"用戶名"; ??
- ????szField2?=?"密碼"; ??
- ????svEdit1?=?"root"; ??
- ????svEdit2?=?"password";????? ??
- ????nResult?=?SdShowDlgEdit2(szTitle,?szMsg,szField1,szField2,?svEdit1,svEdit2);? ??
- ????if?(nResult?=?BACK)?goto?Dlg_SdRegisterUserEx; ??
- ???
- ???
- ? ??
- ??? ??
- ?????
- ???LaunchAppAndWait("net","start?mysql",WAIT); ??
- ?????
- ?????
- ????
- ?????
- ?????
- ?????
- ??????????????????????????????????????????????????????????????????????????? ??
- ????nResult?=?XCopyFile(SRCDIR?+?"\\sql.bat","c:\\xxx\\",EXCLUDE_SUBDIR);??? ??
- ????nResult?=?XCopyFile(SRCDIR?+?"\\init.sql","c:\\xxx\\",EXCLUDE_SUBDIR);???? ??
- ???
- ????
- ???
- ?????????????????????????????????????????? ??
- ???
- ???
- ? ??
- ?if?(LaunchAppAndWait("c:\\xxx\\sql.bat",?"?"?+?svEdit1?+?"?"?+?svEdit2?+?"?",WAIT)?<?0)?then ??
- ??MessageBox?("數(shù)據(jù)庫(kù)創(chuàng)建失敗!請(qǐng)確您的系統(tǒng)中已安裝MySQL?4.1.19.\n如仍無(wú)法解決,請(qǐng)聯(lián)系系統(tǒng)供應(yīng)商!",SEVERE); ??
- ?endif;?? ??
- ??????
- ????DeleteFile("c:\\xxx\\sql.bat"); ??
- ????DeleteFile("c:\\xxx\\init.sql"); ??
- ??? ??
- ??? ??
- ??? ??
- Dlg_SdAskDestPath: ??
- ????szTitle?=?"xxxx系統(tǒng)"; ??
- ????szMsg???=?"請(qǐng)選擇安裝目錄"; ??
- ????nResult?=?SdAskDestPath(?szTitle,?szMsg,?szDir,?0?); ??
- ????TARGETDIR?=?szDir;???????????????????????????????? ??
- ??????
- ????if?(nResult?=?BACK)?goto?Dlg_SdShowDlgEdit2; ??
- ? ??
- Dlg_SetupType:?? ??
- ????szTitle????=?"xxxx系統(tǒng)"; ??
- ????szMsg??????=??"請(qǐng)選擇安裝類(lèi)型"; ??
- ????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????=?"xxxx系統(tǒng)"; ??
- ????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; ??
- ??? ??
- Dlg_SdSelectFolder: ??
- ????szfolder?=?SHELL_OBJECT_FOLDER; ??
- ????szTitle????=?"xxxx系統(tǒng)"; ??
- ????szMsg??????=?""; ??
- ????nResult????=?SdSelectFolder(?szTitle,?szMsg,?szfolder?); ??
- ????SHELL_OBJECT_FOLDER?=?szfolder; ??
- ????if?(nResult?=?BACK)?goto?Dlg_ObjDialogs; ??
- ? ??
- Dlg_SdStartCopy: ??
- ????szTitle?=?"xxxx系統(tǒng)"; ??
- ????szMsg???=?"安裝信息收集完畢,并且獲得安裝權(quán)限,下一步將進(jìn)行文件拷貝。"; ??
- ????listStartCopy?=?ListCreate(?STRINGLIST?); ??
- ??????
- ??????
- ????nResult?=?SdStartCopy(?szTitle,?szMsg,?listStartCopy?);? ??
- ????ListDestroy(listStartCopy); ??
- ????if?(nResult?=?BACK)?goto?Dlg_SdSelectFolder; ??
- ??????
- ????SetStatusWindow(0,?""); ??
- ????Enable(STATUSEX); ??
- ????StatusUpdate(ON,?100); ??
- ????return?0; ??
- end; ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- function?OnMoving() ??
- ????string?szAppPath; ??
- begin ??
- ??????
- ??????
- ????szAppPath?=?TARGETDIR; ??
- ????RegDBSetItem(REGDB_APPPATH,?szAppPath); ??
- ????RegDBSetItem(REGDB_APPPATH_DEFAULT,?szAppPath?^?@PRODUCT_KEY); ??
- end; ??
- ??
- function?OnEnd()???????????????????????????????????? ??
- ??
- ??
- ??
- ??
- ??
- begin?????????????? ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??
- ??????????????????????????????????????????????? ??
- ???XCopyFile(SRCDIR?^?"xxx\\icons\\media\\*.gif",TARGETDIR,EXCLUDE_SUBDIR);? ??
- ???XCopyFile(SRCDIR?^?"xxx\\icons\\teacher\\*.jpg",TARGETDIR,EXCLUDE_SUBDIR);?? ??
- ???CreateDir(TARGETDIR?^?"resc\\");??? ??
- end; ??
- ? ??
- ? ??
- ? ??
- ? ??
- ? ??
- ? ??
- ? ??
- ??
- ??
- ??
- function?OnEnd()???? ??
- string??java_home,?catalina_home,?szKey,?szEnv;?????? ??
- string?icon_dir,?xml_dir,output_dir; ??
- POINTER?pEnv; ??
- begin?????????????? ??
- ??catalina_home=TARGETDIR?+?"\\tomcat5.0.30"; ??
- ??java_home=TARGETDIR?+?"\\j2sdk1.4.2_10";??? ??
- ??szKey="Environment"; ??
- ??RegDBSetDefaultRoot(HKEY_CURRENT_USER);??? ??
- ??RegDBSetKeyValueEx(szKey,"JAVA_HOME",REGDB_STRING,java_home,-1); ??
- ??RegDBSetKeyValueEx(szKey,"CATALINA_HOME",REGDB_STRING,catalina_home,-1); ??
- ??szEnv?=?"Environment"; ??
- ??pEnv?=?&szEnv; ??
- ??SendMessage?(0xffff,?0x001A?,?0,?pEnv?); ??
- ? ??
- ? ??
- ? ??
- ???
////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////an///////////////////////////////////
// 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
NUMBER volumeNum;
//Before using the GetVolumeInformation API you will need to prototype it
prototype KERNEL32.GetVolumeInformation(BYREF STRING, BYREF STRING, NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF STRING, NUMBER);
//prototype for the custom InstallScript function
prototype GetVolumeSerial();
//function definition
function GetVolumeSerial()
STRING lpRootPathName;
STRING lpVolumeNameBuffer;
NUMBER nVolumeNameSize;
NUMBER lpVolumeSerialNumber;
NUMBER lpMaximumComponentLength;
NUMBER lpFileSystemFlags;
STRING lpFileSystemNameBuffer;
NUMBER nFileSystemNameSize;
BOOL APIReturn;
begin
lpRootPathName="d:\\";
nVolumeNameSize=60;
nFileSystemNameSize=60;
//APIReturn=GetVolumeInformation(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize);
APIReturn=GetVolumeInformation(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize);
if (APIReturn) then
volumeNum = lpVolumeSerialNumber ;
if (volumeNum < 0) then
volumeNum = 0 - volumeNum;
endif;
//NumToStr(volumeNum,lpVolumeSerialNumber);
//SprintfBox(INFORMATION, "", "Volume= %s\nVolume Serial= %d", lpRootPathName, lpVolumeSerialNumber);
if (volumeNum > 2139999999 - 135792468) then
//volumeNum = 123456789;
volumeNum = volumeNum - volumeNum/100000000*100000000;
endif;
else
volumeNum = 123456789;
//MessageBox("Failure.",0);
endif;
end ;
prototype getNumString();
function getNumString()
number numSpace;
number numMen;
string tmpString;
begin
//tmpNum = GetWindowHandle(HWND_INSTALL); //安裝主窗口的句柄
//numSpace = GetDiskSpace("c:\\"); //指定驅(qū)動(dòng)器上的空閑磁盤(pán)空間
numSpace = GetDiskSpaceEx("c:\\",KBYTES); //指定驅(qū)動(dòng)器上的空閑磁盤(pán)空間 BYTES
//numMen = GetMemFree(); //運(yùn)行在Microsoft Windows下的一個(gè)應(yīng)用程序可用的內(nèi)存大小
numMen = GetDiskSpaceEx("d:\\",KBYTES);
if numSpace < 10000 then
numSpace = 11360000;
else
numSpace = (numSpace - numSpace/10000*10000)*10000;
endif;
if numMen < 10000 then
numMen = 7521;
else
numMen = numMen - numMen/10000*10000;
endif;
volumeNum = 100000000 + numSpace + numMen;
//NumToStr(tmpString,volumeNum);
// MessageBox(tmpString,0);
end;
//////////////////////////////////////////////////////////////////////////////
//
// 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 szFile;
string szTargetPath;
string szDir;
string szfolder;
string szComponents, szTargetdir;
number nLevel;
LIST listStartCopy;
LIST list;
number nvSize;
string szField1, svEdit1,szField2, svEdit2;
string localNum;
number tmpNum;
string tmpCheckString;
string checkString;
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));
GetVolumeSerial();
//getNumString();
tmpNum = volumeNum;
tmpNum = tmpNum - tmpNum / 100 * 100;
NumToStr(tmpCheckString,tmpNum);
if (tmpCheckString == "0") then
tmpCheckString = "0X";
endif;
checkString = "B" + tmpCheckString + "_";
tmpNum = volumeNum / 100;
tmpNum = tmpNum - tmpNum / 100 * 100;
NumToStr(tmpCheckString,tmpNum);
if (tmpCheckString == "0") then
tmpCheckString = "0X";
endif;
checkString = checkString + "K" + tmpCheckString + "_";
tmpNum = volumeNum / 10000;
tmpNum = tmpNum - tmpNum / 100 * 100;
NumToStr(tmpCheckString,tmpNum);
if (tmpCheckString == "0") then
tmpCheckString = "0X";
endif;
checkString = checkString + "X" + tmpCheckString + "_";
tmpNum = volumeNum / 1000000;
tmpNum = tmpNum - tmpNum / 100 * 100;
NumToStr(tmpCheckString,tmpNum);
if (tmpCheckString == "0") then
tmpCheckString = "0X";
endif;
checkString = checkString + "T" + tmpCheckString;
//MessageBox(checkString,INFORMATION);
//變換volumeNum的值
//B3242_K423_X342_T3423
volumeNum = volumeNum + 135792468;
NumToStr(localNum,volumeNum);
//MessageBox(localNum,INFORMATION);
//copy images
nResult = XCopyFile(SRCDIR ^ "xxx\\icons\\media\\*.gif", "c:\\xxx\\icons\\media\\",EXCLUDE_SUBDIR);
nResult = XCopyFile(SRCDIR ^ "xxx\\icons\\teacher\\*.jpg", "c:\\xxx\\icons\\teacher\\",EXCLUDE_SUBDIR);
CreateDir("c:\\xxx\\resc\\");
if (nResult != 0) then
MessageBox ("圖片拷貝出錯(cuò)!", SEVERE);
endif;
nSetupType = TYPICAL;
TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME;
szDir = TARGETDIR;
SHELL_OBJECT_FOLDER = @FOLDER_NAME;
szName = "";
szCompany = "";
szSerial = "";
Dlg_Start:
// beginning of dialogs label
Dlg_SdWelcome:
szTitle = "xxxx系統(tǒng)";
szMsg = " 確定是否繼續(xù)安裝?繼續(xù)請(qǐng)按【下一步(next)】";
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;
//Dlg_SdLicense:
// szLicenseFile = SUPPORTDIR ^ "license.txt";
// szTitle = "xxxx系統(tǒng)";
// szMsg = "許可協(xié)議";
// szQuestion = "您是否接受該協(xié)議?接受請(qǐng)按【是(Yes)】。繼續(xù)安裝必須接受該協(xié)議。";
// nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
// if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdShowInfoList:
//szFile = SUPPORTDIR ^ "infolist.txt";
//list = ListCreate( STRINGLIST );
//ListReadFromFile( list, szFile );
szTitle = "系統(tǒng)本地編號(hào)";
szMsg = "將下面的本地編號(hào)發(fā)送給權(quán)限授予機(jī)構(gòu),在接收到相應(yīng)的注冊(cè)碼后,您將進(jìn)行繼續(xù)注冊(cè)!";
szField1 = "編號(hào)";
svEdit1 = localNum;
//nResult = SdShowInfoList( szTitle, szMsg, list );
//ListDestroy( list );
nResult = SdShowDlgEdit1(szTitle, szMsg,szField1, svEdit1);
//if (nResult = BACK) goto Dlg_SdLicense;
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SdRegisterUserEx:
szMsg = "請(qǐng)輸入:用戶名、公司名和注冊(cè)號(hào)";
szTitle = "xxxx系統(tǒng)";
nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial );
if (nResult = BACK) goto Dlg_SdShowInfoList;
if (szSerial != checkString) then
MessageBox( "注冊(cè)碼輸入錯(cuò)誤!", SEVERE);
goto Dlg_SdRegisterUserEx;
endif;
Dlg_SdShowDlgEdit2:
szTitle = "數(shù)據(jù)庫(kù)信息";
szMsg = "請(qǐng)輸入數(shù)據(jù)庫(kù)用戶名和數(shù)據(jù)庫(kù)密碼:";
szField1 = "用戶名";
szField2 = "密碼";
svEdit1 = "root";
svEdit2 = "password";
nResult = SdShowDlgEdit2(szTitle, szMsg,szField1,szField2, svEdit1,svEdit2);
if (nResult = BACK) goto Dlg_SdRegisterUserEx;
//SdShowMsg ("下面進(jìn)行數(shù)據(jù)庫(kù)初始化操作,請(qǐng)勿手動(dòng)關(guān)閉彈出窗口!", TRUE);
//Delay(2);
//啟動(dòng)mysql
LaunchAppAndWait("net","start mysql",WAIT);
//LaunchAppAndWait("net","stop mysql",WAIT);
//LaunchAppAndWait("C:\\Program Files\\MySQL\\MySQL Server 4.1\\bin\\mysql.exe"," -uroot -ppassword<" + SRCDIR ^ "test.sql",NOWAIT);
// LaunchAppAndWait("C:\\Program Files\\MySQL\\MySQL Server 4.1\\bin\\mysql.exe"," -h localhost -u root -p password<" + SRCDIR ^ "test.sql",WAIT) ;
//LaunchApp(WINDIR ^ "Notepad.exe",SRCDIR ^ "init.sql");
//LaunchAppAndWait(SRCDIR ^ "sql.bat"," root password ",WAIT);
///LaunchAppAndWait("C:\\Program Files\\MySQL\\MySQL Server 4.1\\bin\\mysql.exe ","mysql -uroot -ppassword<" + SRCDIR ^ "test.sql",NOWAIT);
nResult = XCopyFile(SRCDIR + "\\sql.bat","c:\\xxx\\",EXCLUDE_SUBDIR);
nResult = XCopyFile(SRCDIR + "\\init.sql","c:\\xxx\\",EXCLUDE_SUBDIR);
//if (LaunchAppAndWait(SRCDIR + "\\sql.bat", " root password",WAIT) < 0) then
//MessageBox ("數(shù)據(jù)庫(kù)創(chuàng)建失敗!請(qǐng)確您的系統(tǒng)中已安裝MySQL 4.1.19.\n如仍無(wú)法解決,請(qǐng)聯(lián)系系統(tǒng)供應(yīng)商!",SEVERE);
//endif;
//NumToStr(tmpCheckString,LaunchAppAndWait("c:\\xxx\\sql.bat", " root password",WAIT));
//MessageBox(tmpCheckString,SEVERE);
if (LaunchAppAndWait("c:\\xxx\\sql.bat", " " + svEdit1 + " " + svEdit2 + " ",WAIT) < 0) then
MessageBox ("數(shù)據(jù)庫(kù)創(chuàng)建失敗!請(qǐng)確您的系統(tǒng)中已安裝MySQL 4.1.19.\n如仍無(wú)法解決,請(qǐng)聯(lián)系系統(tǒng)供應(yīng)商!",SEVERE);
endif;
//DeleteDir("c:\\xxx\\",ALLCONTENTS); //刪除這個(gè)臨時(shí)目錄
DeleteFile("c:\\xxx\\sql.bat");
DeleteFile("c:\\xxx\\init.sql");
Dlg_SdAskDestPath:
szTitle = "xxxx系統(tǒng)";
szMsg = "請(qǐng)選擇安裝目錄";
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
//if (nResult = BACK) goto Dlg_SdRegisterUserEx;
if (nResult = BACK) goto Dlg_SdShowDlgEdit2;
Dlg_SetupType:
szTitle = "xxxx系統(tǒng)";
szMsg = "請(qǐng)選擇安裝類(lèi)型";
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 = "xxxx系統(tǒng)";
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;
Dlg_SdSelectFolder:
szfolder = SHELL_OBJECT_FOLDER;
szTitle = "xxxx系統(tǒng)";
szMsg = "";
nResult = SdSelectFolder( szTitle, szMsg, szfolder );
SHELL_OBJECT_FOLDER = szfolder;
if (nResult = BACK) goto Dlg_ObjDialogs;
Dlg_SdStartCopy:
szTitle = "xxxx系統(tǒng)";
szMsg = "安裝信息收集完畢,并且獲得安裝權(quán)限,下一步將進(jìn)行文件拷貝。";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(szName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,szName,AFTER);
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) goto Dlg_SdSelectFolder;
// 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 OnEnd()
// //string java_home, catalina_home, szKey, szEnv;
// string szKey, szEnv, svClassPath;
// string icon_dir, xml_dir,output_dir;
// number nRegSize;
// pointer pEnv;
begin
//
// //catalina_home=TARGETDIR + "\\tomcat5.0.30";
// //java_home=TARGETDIR + "\\j2sdk1.4.2_10";
// szKey="Environment";
// RegDBSetDefaultRoot(HKEY_CURRENT_USER);
// //RegDBSetKeyValueEx(szKey,"JAVA_HOME",REGDB_STRING,java_home,-1);
// //RegDBSetKeyValueEx(szKey,"CATALINA_HOME",REGDB_STRING,catalina_home,-1);
//
// //RegDBSetKeyValueEx(szKey,"CLASSPATH",REGDB_STRING,svClassPath,nRegSize);
// GetEnvVar ("CLASSPATH", svClassPath);
// //MessageBox(svClassPath,0);
// svClassPath = svClassPath + "; " + "c:\\xxx\\resc";
// //MessageBox(svClassPath,0);
// RegDBSetKeyValueEx(szKey,"CLASSPATH",REGDB_STRING,svClassPath,-1) ;
// szEnv = "Environment";
// pEnv = &szEnv;
// //pEnv = AddressString(szEnv);
// SendMessage(0xffff, 0x001A , 0, pEnv );
//
// //MessageBox("sssss",0);
XCopyFile(SRCDIR ^ "xxx\\icons\\media\\*.gif",TARGETDIR,EXCLUDE_SUBDIR);
XCopyFile(SRCDIR ^ "xxx\\icons\\teacher\\*.jpg",TARGETDIR,EXCLUDE_SUBDIR);
CreateDir(TARGETDIR ^ "resc\\");
end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////下面是一些設(shè)定tomcat或者jdk的環(huán)境變量的代碼/////////////非本系統(tǒng)/////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function OnEnd()
string java_home, catalina_home, szKey, szEnv;
string icon_dir, xml_dir,output_dir;
POINTER pEnv;
begin
catalina_home=TARGETDIR + "\\tomcat5.0.30";
java_home=TARGETDIR + "\\j2sdk1.4.2_10";
szKey="Environment";
RegDBSetDefaultRoot(HKEY_CURRENT_USER);
RegDBSetKeyValueEx(szKey,"JAVA_HOME",REGDB_STRING,java_home,-1);
RegDBSetKeyValueEx(szKey,"CATALINA_HOME",REGDB_STRING,catalina_home,-1);
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (0xffff, 0x001A , 0, pEnv );
? ? ?對(duì)應(yīng)的 vb 注冊(cè)碼解碼的核心程序(KeyGen.frm)如下: ? ? VERSION 5.00
Begin VB.Form keyGen
Appearance = 0 'Flat
BackColor = &H80000001&
BorderStyle = 5 'Sizable ToolWindow
Caption = "**系統(tǒng)注冊(cè)碼生成器"
ClientHeight = 1290
ClientLeft = 60
ClientTop = 330
ClientWidth = 4545
DrawMode = 1 'Blackness
FillStyle = 0 'Solid
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
OLEDropMode = 1 'Manual
ScaleHeight = 1290
ScaleMode = 0 'User
ScaleWidth = 4545
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton genButton
Appearance = 0 'Flat
BackColor = &H80000001&
Caption = "生成"
Height = 300
Left = 3480
MaskColor = &H80000001&
Style = 1 'Graphical
TabIndex = 4
Top = 240
UseMaskColor = -1 'True
Width = 615
End
Begin VB.TextBox snText
Appearance = 0 'Flat
BackColor = &H80000001&
Height = 300
Left = 960
Locked = -1 'True
TabIndex = 3
Top = 720
Width = 3135
End
Begin VB.TextBox machineText
Appearance = 0 'Flat
BackColor = &H80000001&
Height = 300
Left = 960
TabIndex = 2
Top = 240
Width = 2295
End
Begin VB.Label snLabel
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000001&
BackStyle = 0 'Transparent
Caption = "注冊(cè)碼"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 1
Top = 840
Width = 735
End
Begin VB.Label machineLabel
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000001&
BackStyle = 0 'Transparent
Caption = "機(jī)器碼"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 0
Top = 360
Width = 735
WordWrap = -1 'True
End
End
Attribute VB_Name = "keyGen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub genButton_Click()
Dim distNum As Double
Dim intTmp As Double
Dim mid As Long
Dim strSN As String
If (VBA.Trim(machineText) <> "") Then
If (IsNumeric(VBA.Trim(machineText)) And VBA.Trim(machineText) > 135792468 And VBA.Trim(machineText) < 2139999999) Then
distNum = machineText
Else
distNum = 123456789 + 135792468
End If
distNum = distNum - 135792468
strSN = "B"
intTmp = distNum
mid = intTmp - Fix(intTmp / 100) * 100
If mid = 0 Then
strSN = strSN + "0X"
Else
strSN = strSN + VBA.Trim(Str(mid))
End If
strSN = strSN + "_"
strSN = strSN + "K"
intTmp = Fix(intTmp / 100)
mid = intTmp - Fix(intTmp / 100) * 100
If mid = 0 Then
strSN = strSN + "0X"
Else
strSN = strSN + VBA.Trim(Str(mid))
End If
strSN = strSN + "_"
strSN = strSN + "X"
intTmp = Fix(intTmp / 100)
mid = intTmp - Fix(intTmp / 100) * 100
If mid = 0 Then
strSN = strSN + "0X"
Else
strSN = strSN + VBA.Trim(Str(mid))
End If
strSN = strSN + "_"
strSN = strSN + "T"
intTmp = Fix(intTmp / 100)
mid = intTmp - Fix(intTmp / 100) * 100
If mid = 0 Then
strSN = strSN + "0X"
Else
strSN = strSN + VBA.Trim(Str(mid))
End If
snText = strSN
End If
End Sub
?
|