日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

InstallShield For .Net制作.Net项目安装包之完整代码

發(fā)布時(shí)間:2023/11/30 asp.net 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 InstallShield For .Net制作.Net项目安装包之完整代码 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

這是我做過的一個(gè)B/S項(xiàng)目的安裝包代碼(InstallShield For .Net),安裝界面非常漂亮,現(xiàn)在跟大家一起分享一下:

/
//
//? File Name:??? Setup.rul
//
//? Description:? InstallShield script
//
//? Comments:???? This minimal project is intended for advanced users.
//??????????????? To create a robust project with step-by-step
//????? instructions, use the Project Wizard.
//
/

// Include header files /
#include "ifx.h"
#include "CreateDB.Rul"??
#include "System.rul"
#include "IIS.rul"???
#include "CustomPassword.Rul"?
???
// string defines
#define DBSERVER "(local)"//數(shù)據(jù)庫服務(wù)器
#define WEBNAME "****.net"
#define ****NetReg "****\\****.net"
#define INSTALL_DB_FILE_DELETE "****.iss"??????
#define DBFILENAME1 "****.MDF"??
#define DBFILENAME2 "****.LDF"?

installation declarations ///

??? // In order to have your InstallScript function executed as a custom
??? // action by the Windows Installer, it must be prototyped as an
??? // entry-point function.

??? // The keyword export identifies MyFunction() as an entry-point function.
??? // The argument it accepts must be a handle to the Installer database.
???
????? /* export prototype MyFunction(HWND); */?

??? // To Do:? Declare global variables, define constants, and prototype?
??? //???????? defined and DLL functions here.


// ----- DLL function prototypes -----


??? // your DLL function prototypes


// ---- script function prototypes -----


??? // your script function prototypes

??? // your global variables

//全局變量定義
STRING szSQLPATH, szDatabaseDestinationPath,svEdit1,szTemp,DBNAME;
STRING? svServer, svUser, svPassword, svDBName;
STRING? szVer,szParameter;
BOOL bDeleteDB, bHaveOldDB, bHaveSql ;
int i;?
VARIANT SQLOBJ;
NUMBER? nvFileHandle;

///
//??????????????????????????????????????????????????????????????????????????
//? 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, sdResult, nSetupType;
??? NUMBER? nRootKey,nType, nSize,abc;
??? string? szTitle, szMsg;
??? string? szLicenseFile, szQuestion;
??? string? szDir;
??? LIST??? listStartCopy;
??? STRING szQuestion1, szQuestion2;
begin
?//系統(tǒng)初始安裝過程?
?DBNAME="*";
??? SetTitle( @COMPANY_NAME + " - " + @PRODUCT_NAME + "? 安裝向?qū)?#34;, 24, WHITE );
??? SetTitle( @COMPANY_NAME + " - " + @PRODUCT_NAME + "? 安裝向?qū)?#34;, 0, BACKGROUNDCAPTION );????????????????????
??? UNINSTALL_DISPLAYNAME = "*.net";

??? SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
???
??? svServer = "localhost";
??? svDBName = DBNAME;
???
??? bHaveOldDB = FALSE;
??? bDeleteDB = FALSE;
???
??? szDir = INSTALLDIR;

Dlg_Start:
??? SdShowMsg("正在檢測操作系統(tǒng)版本...",TRUE);
?Delay(1);
?nResult = CheckSystem(2000);
?
?if ( nResult != 0 ) then
? switch( nResult )
?? case 1:
??? szMsg = "請使用 windows 2000 版本及以上";
?? case 2:
??? szMsg = "初始化檢測函數(shù)失敗";
? endswitch;
? MessageBox(szMsg, SEVERE);
? abort;
?endif;
??
?SdShowMsg("正在檢測 Internet 信息服務(wù)...", TRUE);
?Delay(1);
?nResult = CheckIIS(5);
?
?if ( nResult != 0 ) then
? switch ( nResult )
???????? case 1:
????????? szMsg = "初始化檢測函數(shù)失敗";
???????? case 2:
????????? szMsg = "本機(jī)沒安裝IIS";
???????? case 3:
????????? szMsg = "本機(jī) IIS 版本不是5及以上";
? endswitch;
? MessageBox(szMsg, SEVERE);
? abort;
?endif;
?
?SdShowMsg("正在檢測 Microsoft DotNet Framework...",TRUE);
?Delay(2);
?nResult = CheckSystem(3705);
?
?if ( nResult != 0 ) then
? switch ( nResult )
???????? case 1:
????????? szMsg = "初始化檢測函數(shù)失敗";?
??? MessageBox(szMsg, SEVERE);
??? abort;
???????? case 2:
????????? //szMsg = "本機(jī)沒安裝.NetFrameWork,請先安裝.NetFrameWork軟件包";
????????? //運(yùn)行.NetFrameWork安裝包???
??? SdShowMsg("正在安裝 Microsoft DotNet Framework...",TRUE);
????????? if LaunchAppAndWait(SUPPORTDIR ^ "dotnetfx.exe", "", WAIT) < 0 then
??????? szMsg = "安裝.NetFrameWork軟件包出錯(cuò),請手工安裝!";
????????? MessageBox(szMsg, SEVERE);
????????? abort;
??? endif;
??? SdShowMsg("成功安裝 Microsoft DotNet Framework...",TRUE);
??? Delay(2);
? endswitch;
?endif;
???????
?SdShowMsg("正在檢測數(shù)據(jù)庫服務(wù)...", TRUE);
?Delay(1);
?nResult = CheckSQLServer(svServer, szSQLPATH, szDatabaseDestinationPath, 8);

?if ( nResult != 0 ) then
? switch( nResult )
????? case 1:
?????? szMsg = "初始化檢測函數(shù)失敗";
????? case 2:
?????? szMsg = "本機(jī)沒安裝SQL Server";
????? case 3:
?????? szMsg = "本機(jī)SQL Server版本不是SQL Server 2000";
????? case 4:
?????? szMsg = "無法檢測到SQL數(shù)據(jù)庫服務(wù)器安裝路徑";
????? case 4:
?????? szMsg = "無法檢測到SQL數(shù)據(jù)庫文件存放路徑";?????
? endswitch;
? MessageBox(szMsg, SEVERE);
? abort;
?else
? bHaveSql=TRUE;
?endif;

??? SdShowMsg("...", FALSE);

Dlg_SdWelcome:
?//顯示歡迎界面

??? szTitle = "*.net";
??? szMsg?? = "??? ***軟件發(fā)展有限公司 *.net 安裝向?qū)⒃谟?jì)算機(jī)中安裝 *.net。
????????????????若要繼續(xù),請單擊“下一步”。";
??? sdResult = SdWelcome( szTitle, szMsg );
??? if (sdResult = BACK) goto Dlg_Start;

Dlg_SdLicense:
?//顯示許可協(xié)議
??? szLicenseFile = SUPPORTDIR ^ "許可協(xié)議.txt";
??? szTitle??? = "";
??? szMsg????? = "";
??? szQuestion = "";
??? sdResult??? = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
??? if (sdResult = BACK) goto Dlg_SdWelcome;

AskDatabasePwd:
?//詢問數(shù)據(jù)庫訪問密碼??
??? SdShowMsg("正在檢測數(shù)據(jù)庫...", TRUE);
?Delay(1);?????
?? nResult= SdCustomPassword("PasswordDlh","??? 安裝程序需要SQL數(shù)據(jù)庫服務(wù)器
??????????? "超級(jí)用戶權(quán)限,請輸入SQL數(shù)據(jù)庫服務(wù)器超級(jí)用戶登錄信息",
????????????"輸入SQL數(shù)據(jù)庫服務(wù)器超級(jí)用戶登錄信息","用? 戶","口? 令",
????????????svUser,svPassword);
?? if (nResult = BACK) goto Dlg_SdLicense;

?? SdShowMsg("安裝程序正在啟動(dòng)SQL數(shù)據(jù)庫服務(wù)器...",TRUE);
?? SQLOBJ=CreateObject("SQLDMO.SQLServer");
?? if IsObject(SQLOBJ) then
?? try?
??? try
???? SQLOBJ.Start(TRUE, "(local)",svUser,svPassword);
??? catch??????????????????????????????????
???? SQLOBJ.Connect("(local)", svUser, svPassword);?????
??? endcatch;?
??? if !SQLOBJ.VerifyConnection then
????? MessageBox("SQL數(shù)據(jù)庫服務(wù)器不能啟動(dòng),安裝程序?qū)⑼顺?#xff01;",SEVERE);??
????? abort;
??? endif;????
?? catch
????? MessageBox("SQL數(shù)據(jù)庫服務(wù)器不能啟動(dòng),安裝程序?qū)⑼顺?#xff01;",SEVERE);??
????? abort;
?? endcatch;??
?? else
???? MessageBox("沒有找到SQL數(shù)據(jù)庫服務(wù)器,安裝程序?qū)⑼顺?#xff01;",SEVERE);??
???? abort;
?? endif;???
?? SdShowMsg("...",FALSE);?
?????????????
?? bHaveSql=TRUE;
???????????
Dlg_InputDBName:???
?? svEdit1=DBNAME;????
?? // Get a target folder name from the user.
?? nResult=SdShowDlgEdit1 ("請輸入安裝數(shù)據(jù)庫名", "請輸入安裝數(shù)據(jù)庫名:",
? ???????????????????????? "數(shù)據(jù)庫名:", svEdit1);
?? if (nResult< 0) then
????? MessageBox ("創(chuàng)建對話窗口失敗!", SEVERE);??????????????????????
?? elseif (nResult==BACK)then??
????? goto AskDatabasePwd;
?? elseif(StrLength(svEdit1)==0) then
????? MessageBox ("數(shù)據(jù)庫名不能為空!", SEVERE);??????????????????????
????? goto Dlg_InputDBName;
?? endif;
?? DBNAME=svEdit1;

?? //檢查數(shù)據(jù)庫是否存在
?
??? for i=1 to SQLOBJ.Databases.Count
????? szTemp=SQLOBJ.Databases.Item(i).Name;
????? StrToUpper(szTemp,szTemp);
????? if (szTemp==svEdit1) then?
?????? MessageBox ("數(shù)據(jù)庫"+svEdit1+"已經(jīng)存在,點(diǎn)擊“確定”繼續(xù)安裝,
???????????????????"不會(huì)對現(xiàn)有數(shù)據(jù)庫產(chǎn)生任何影響……", INFORMATION);??
??????? /*if (AskYesNo("數(shù)據(jù)庫"+svEdit1+"已經(jīng)存在,如果繼續(xù),
???????????????????????"現(xiàn)存的數(shù)據(jù)庫將被刪除,是否繼續(xù)?",NO)==NO) then
????????? goto Dlg_InputDBName;
???????? else
?????????? bDeleteDB = TRUE;
???????? endif;*/
????? endif;
??? endfor;????????
??? if (sdResult = BACK) goto AskDatabasePwd;
?????????
Dlg_SdAskVirtualDirectories:
?//詢問虛擬目錄
??? if (sdResult = BACK) goto Dlg_SdAskVirtualDirectories;

Dlg_SdAskDestPath:?
??? //讀取注冊表
?/*nRootKey = HKEY_CURRENT_USER;
?if (RegDBSetDefaultRoot (nRootKey) < 0) then
???? MessageBox("初始化失敗", SEVERE);
?? else????????????????????????
???? abc = RegDBGetKeyValueEx(****NetReg,"InstallPath",nType,szDir,nSize);
? if (abc < 0) then???? */
????? szTitle = "";
????? szMsg?? = "";
????? sdResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
????? INSTALLDIR = szDir;
????? if (sdResult = BACK) goto AskDatabasePwd;
? /*else
?? StrSub(szDir, szDir, 0, StrFind(szDir, "****.net"));
?? INSTALLDIR = szDir;
? endif;
?endif;? */

Dlg_SdStartCopy:
??? szTitle = "";
??? szMsg?? = "";
??? listStartCopy = ListCreate( STRINGLIST );
???
??? ListAddString(listStartCopy, "安裝組件:", AFTER);
??? ListAddString(listStartCopy, "\tWeb程序" , AFTER);
??? ListAddString(listStartCopy, "\t幫助文檔" , AFTER);
??? ListAddString(listStartCopy, "\t軟件狗驅(qū)動(dòng)" , AFTER);
??? ListAddString(listStartCopy, "\t數(shù)據(jù)庫配置工具" , AFTER);
??? ListAddString(listStartCopy, "", AFTER);
???
??? ListAddString(listStartCopy, "目標(biāo)目錄:", AFTER);
??? ListAddString(listStartCopy, "\t" + INSTALLDIR , AFTER);
??? ListAddString(listStartCopy, "", AFTER);
???
??? ListAddString(listStartCopy, "命令目錄:", AFTER);
??? ListAddString(listStartCopy, "\t***-****.net行業(yè)管理系統(tǒng)" , AFTER);
??? ListAddString(listStartCopy, "", AFTER);
???
??? StrToUpper(szMsg, svDBName);
??? ListAddString(listStartCopy, "數(shù)據(jù)庫:", AFTER);
??? ListAddString(listStartCopy, "\t" + szMsg, AFTER);
??? ListAddString(listStartCopy, "", AFTER);
???
??? ListAddString(listStartCopy, "虛擬目錄:", AFTER);
??? ListAddString(listStartCopy, "\t" + WEBNAME , AFTER);
??? ListAddString(listStartCopy, "\t本機(jī)使用 http://localhost/" +
????WEBNAME + " 進(jìn)行訪問", AFTER);
??? ListAddString(listStartCopy, "", AFTER);
???
??? szMsg = "";

??? sdResult = SdStartCopy( szTitle, szMsg, listStartCopy );
??? ListDestroy(listStartCopy);
??? if (sdResult = BACK) goto Dlg_SdAskDestPath;

??? Enable(STATUSEX);

??? return 0;
end;

///
//
//? FUNCTION:?? OnFirstUIAfter
//
//? EVENT:????? FirstUIAfter event is sent after file transfer, when installation
//????????????? is run for the first time on given machine. In this event handler
//????????????? installation usually displays UI that will inform end user that
//????????????? installation has been completed successfully.
//
///?
function OnFirstUIAfter()
??? STRING szTitle, szMsg, szMsg1, szMsg2, szOption1, szOption2;
??? NUMBER bOpt1, bOpt2, nResult, nType, nSize;
??? NUMBER nRootKey, SQLVersion;????
?? STRING szTemp,svResult, svTime, ProductVersion;
begin
?
?/*SdShowMsg("安裝軟件狗驅(qū)動(dòng)...", TRUE);
??? nResult = InstallDogDriver();
??? if ( nResult != 0 ) then
??? MessageBox("安裝軟件狗驅(qū)動(dòng)程序失敗,請手工安裝軟件狗驅(qū)動(dòng)程序!\n"
????????????? +'手工安裝,請執(zhí)行'+INSTALLDIR ^ '\\****\\
??????????????軟件狗驅(qū)動(dòng)程序\\****.exe',SEVERE);
??? endif; */
??????????
??? SdShowMsg("安裝產(chǎn)品數(shù)據(jù)庫...", TRUE);
??? if (bDeleteDB) then
??????? nResult = DeleteDatabase(svDBName);
??????? if ( nResult != 0 ) then
?? szMsg = "刪除舊數(shù)據(jù)庫失敗";
?? MessageBox(szMsg, SEVERE);
???? endif;
??? endif;

? Disable(STATUSEX);?????????????
? OpenFileMode (FILE_MODE_APPEND);
? //創(chuàng)建數(shù)據(jù)庫安裝文件
? if (CreateFile (nvFileHandle, SUPPORTDIR, INSTALL_DB_FILE_DELETE) < 0) then
???? MessageBox ("創(chuàng)建文件失敗!", SEVERE);
???? abort;
? else
???? szMsg = "declare @dttm varchar(55) \n"
?????????? +"select? @dttm=convert(varchar,getdate(),113)\n"
?????????? +"raiserror('Beginning InstPubs.SQL at %s ....',1,1,
???????????@dttm) with nowait \n"
?????????? +"GO \n"
?????????? +"use master \n"
?????????? +"go \n"

?????????? +"raiserror('Creating "+svEdit1+" database....',0,1) \n"
?????????? +"go \n"
???
?????????? +" sp_attach_db '"+svEdit1+"',@filename1='"+
???????????INSTALLDIR+"****.net\\DataBase\\"+DBFILENAME1+"',"+"@filename2='"
???????????+INSTALLDIR+"****.net\\DataBase\\"+DBFILENAME2+"' \n"
?????????? +"go\n";

???? if (WriteLine(nvFileHandle, szMsg) < 0) then
??????? MessageBox("寫入文件發(fā)生錯(cuò)誤!", SEVERE);
??????? abort;
???? endif;
?? endif;
?? CloseFile (nvFileHandle);

?? szParameter=" -U "+svUser+" -P "+svPassword+" -i "+
???SUPPORTDIR+INSTALL_DB_FILE_DELETE+" -o c:\\Errlog.txt -n";


?? if bHaveSql then
??? SdShowMsg("開始安裝數(shù)據(jù)庫,請等待...",TRUE);
??? Delay(5);
??? szSQLPATH=INSTALLDIR^"****.net\\DataBase\\OSQL.EXE";
??? if LaunchAppAndWait(szSQLPATH,szParameter,WAIT)<0 then
????? MessageBox("安裝數(shù)據(jù)庫失敗,請手工安裝數(shù)據(jù)庫!",SEVERE);
??? endif;?????
???? SdShowMsg("...",FALSE);
??? endif;??

??? if LaunchAppAndWait(INSTALLDIR ^ "****.net\\bin\\tools\\****.exe",
????"", NOWAIT) < 0 then
???? szMsg = "運(yùn)行數(shù)據(jù)庫配置工具出錯(cuò),請手工安裝!";
?????? MessageBox(szMsg, SEVERE);
?endif;?
????????????
??? if LaunchAppAndWait(SUPPORTDIR ^ "iewebcontrols.msi", "", WAIT) < 0 then
???? szMsg = "安裝瀏覽器組件出錯(cuò),請手工安裝!";
?????? MessageBox(szMsg, SEVERE);
?endif;
?????????????
??? //修改注冊表
?nRootKey = HKEY_CURRENT_USER;
?if (RegDBSetDefaultRoot (nRootKey) < 0) then
???? MessageBox("初始化失敗", SEVERE);
?? endif;
??? nType = REGDB_STRING;
??
?? ProductVersion = @PRODUCT_VERSION;
??
? RegDBSetKeyValueEx(****NetReg,"DatabaseName",nType,svDBName,nSize);
? RegDBSetKeyValueEx(****NetReg,"InstallPath",nType,INSTALLDIR^"****.net",nSize);
??
? //StrSub(svResult, ProductVersion, 0, StrFind(ProductVersion, "."));
? //StrSub(ProductVersion, ProductVersion, (StrFind(ProductVersion, ".") + 1),?
??(StrLength(ProductVersion) - StrFind(ProductVersion, ".")));
? RegDBSetKeyValueEx(****NetReg,"Ver",nType,ProductVersion,nSize);

?? GetSystemInfo (DATE, nResult, svResult);
?? svTime = svResult;
?? GetSystemInfo (TIME, nResult, svResult);
?? svTime = svTime + " " + svResult;
? RegDBSetKeyValueEx(****NetReg,"Date",nType,svTime,nSize);?
???????????
?Disable(STATUSEX);

??? szTitle = "";
??? szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
??? szMsg1 = szMsg1 + "\n\n客戶端訪問請使用 IE 6.0 及以上版本!";
?szMsg2 = "";
??? szOption1 = "";
??? szOption2 = "";
??? bOpt1? = FALSE;
??? bOpt2? = FALSE;

??? SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
end;

// --- include script file section ---

?


?


為了避免不必要的麻煩,以上代碼我特地用****代替了某些關(guān)鍵字。

相關(guān)IncludeFiles

轉(zhuǎn)載于:https://www.cnblogs.com/liang_jumps/archive/2004/10/12/51179.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的InstallShield For .Net制作.Net项目安装包之完整代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。