InstallShield用于配置 IIS 的 InstallScrip(续)
//** -2 没有找到指定的站点(异常);//** -3 获取 W3SVC 失败;
//** -4 获取 W3SVC 失败(异常);
//** -5 设置指定站点状态失败(异常);
//** -6 参数 nvState 不正确;
//** @Description 注意,对于已经停止的站点(4),不能转为暂停,否则会返回 -5
//*********************************************************
function xzSetWebSiteState(nvSiteIndex, nvState)
OBJECT objW3SVC, objWebSite;
NUMBER nvResult;
STRING szInfo;
begin
szInfo = IFX_PRODUCT_NAME + " 安装程序正在尝试设置指定 IIS 站点状态,请稍等 ...";
SdShowMsg(szInfo, TRUE);
if ( nvState = 2 || nvState = 4 || nvState = 6 ) then
try
set objW3SVC = CoGetObject("IIS://" + xzIISConfig_LocalComputerName + "/W3SVC", "");
if (IsObject(objW3SVC)) then
try
set objWebSite = objW3SVC.GetObject("IIsWebServer", nvSiteIndex);
if (IsObject(objWebSite)) then
try
if ( nvState = 2 ) then
objWebSite.Start();
else
if ( nvState = 4 ) then
objWebSite.Stop();
else
if ( nvState = 6 ) then
objWebSite.Pause();
endif;
endif;
endif;
nvResult = 1;
try
nvResult = objWebSite.ServerState;
catch
endcatch;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态成功。";
SdShowMsg(szInfo, TRUE);
catch
//设置指定站点状态失败(异常)
nvResult = -5;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态失败:异常";
SdShowMsg(szInfo, TRUE);
endcatch;
else
//没有找到指定的站点
nvResult = -1;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态失败:没有找到指定的站点";
SdShowMsg(szInfo, TRUE);
endif;
catch
//没有找到指定的站点(异常)
nvResult = -2;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态失败:没有找到指定的站点(异常)";
SdShowMsg(szInfo, TRUE);
endcatch;
else
//获取 W3SVC 失败
nvResult = -3;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态失败:获取 W3SVC 失败";
SdShowMsg(szInfo, TRUE);
endif;
catch
//获取 W3SVC 失败(异常)
nvResult = -4;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态失败:获取 W3SVC 失败(异常)";
SdShowMsg(szInfo, TRUE);
endcatch;
else
//参数 nvState 不正确;
nvResult = -6;
szInfo = IFX_PRODUCT_NAME + " 安装程序设置 IIS 站点状态失败:参数 nvState 不正确";
SdShowMsg(szInfo, TRUE);
endif;
SdShowMsg("", FALSE);
return nvResult;
end;
调用范例一:
//---------------------------------------------------------------------------
// OnFirstUIAfter
//
// The OnFirstUIAfter event called by the framework after the file transfer
// of the setup when the setup is running in first install mode. By default
// this event displays UI that informs the end user that the setup has been
// completed successfully.
//---------------------------------------------------------------------------
function OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
NUMBER bOpt1, bOpt2;
STRING szWebSiteRootPath, szWebSiteComment, szIPBands, szHost, svValue;
NUMBER nzPort, nzResult;
STRING szCommandLine, szIconPath, szWorkingDir, szShortCutKey;
NUMBER nIcon, nFlag;
begin
Disable(STATUSEX);
szWebSiteRootPath = INSTALLDIR ^ "Help";
szWebSiteComment = "XiaoZhu.com";
szIPBands = "";
nzPort = 80;
szHost = "";
nzResult = xzFindWebSite("", "", 80);
if ( nzResult > 0 ) then
nzResult = xzChangeWebSite(nzResult, szWebSiteRootPath, szWebSiteComment, szIPBands, nzPort, szHost, TRUE);
if (nzResult < 0) then
NumToStr(svValue, nzResult);
MessageBox("更改站点设置失败,请联系系统管理员。(" + svValue + ")", WARNING);
endif;
else
nzResult = xzCreateWebSite(szWebSiteRootPath, szWebSiteComment, szIPBands, nzPort, szHost, TRUE);
if (nzResult < 0) then
NumToStr(svValue, nzResult);
MessageBox("创建新站点失败,请联系系统管理员。(" + svValue + ")", WARNING);
endif;
endif;
bOpt1= FALSE;
bOpt2= FALSE;
szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
////////////////////////////////////////////
//打开浏览器浏览制定的网页
szCommandLine = ProgramFilesFolder ^ "Internet Explorer\\iexplore.exe";
LaunchAppAndWait(szCommandLine, "http://127.0.0.1/Readme.htm", NOWAIT);
//LaunchAppAndWait(szCommandLine, INSTALLDIR ^ "help\\Readme.htm", NOWAIT);
////////////////////////////////////////////
//运行数据库设置程序
LaunchAppAndWait(INSTALLDIR ^ "xzSQLDeploy.exe", "", NOWAIT);
////////////////////////////////////////////
//在程序组中添加快捷方式
szWorkingDir= INSTALLDIR;
nIcon = 0;
szShortCutKey = "";
nFlag = REPLACE|RUN_MINIMIZED;
/*
//方法二 A:
szIconPath = "%SystemDrive%\\Program Files\\Internet Explorer\\iexplore.exe";
szCommandLine = szIconPath;
LongPathToQuote(szCommandLine, TRUE);
szCommandLine = szCommandLine + " " + "http://www.XiaoZhu.com";
AddFolderIcon(FOLDER_PROGRAMS ^ @PRODUCT_NAME, "Readme1", szCommandLine, szWorkingDir, szIconPath, 0, szShortCutKey, nFlag);
*/
////方法二 B:
szIconPath = ProgramFilesFolder ^ "Internet Explorer\\iexplore.exe";
szCommandLine = szIconPath;
LongPathToQuote(szCommandLine, TRUE);
szCommandLine = szCommandLine + " " + "http://www.XiaoZhu.com";
AddFolderIcon(FOLDER_PROGRAMS ^ @PRODUCT_NAME, "Readme2", szCommandLine, szWorkingDir, szIconPath, 0, szShortCutKey, nFlag);
end;
页:
[1]