📄 is_main.pas
字号:
(* isx_main.pas: Pascal Scripts routines for Inno Setup Windows installer.
* ====================================================================
* Copyright (c) 2000-2004 CollabNet. All rights reserved.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://subversion.tigris.org/license-1.html.
* If newer versions of this license are posted there, you may use a
* newer version instead, at your option.
*
* This software consists of voluntary contributions made by many
* individuals. For exact contribution history, see the revision
* history and logs, available at http://subversion.tigris.org/.
* =================================================================== *)
// ****************************************************************************
// Global variables
var
// Required dlls
g_bMsVcpNotFound: Boolean; // Visual C++ 6.0 Runtimes
g_bShFolderNotFound: Boolean; // shfolder.dll
// Apache
g_bHandleApache: Boolean;
g_sApachePath: String;
g_sApachePathBin: String;
g_sApachePathConf: String;
g_sApachePathModules: String;
const
// Visual C++ 6.0 Runtime file related
FILE_MSVCPDLL = 'msvcp60.dll';
URL_VCREDIST = 'http://support.microsoft.com/support/kb/articles/Q259/4/03.ASP';
// shfolder.dll related
FILE_SHFOLDERDLL = 'shfolder.dll';
URL_SHFREDIST = 'http://download.microsoft.com/download/platformsdk/Redist/5.50.4027.300/W9XNT4/EN-US/shfinst.EXE';
// Apache
REG_KEY_APACHE_SERVICE = 'SYSTEM\CurrentControlSet\Services\Apache2';
APACHE_VER_MIN = '{#= apache_ver_min}';
// Status codes for modules in httpd.conf
STATUS_NONE = 0;
STATUS_DISABLED = 1;
STATUS_ENABLED = 2;
// ***************************************************************************
// UninsHs stuff
function ComponentList(Default: string):string;
begin
Result := WizardSelectedComponents(False);
end;
function SkipCurPage(CurPage: Integer): Boolean;
begin
if Pos('/SP-', UpperCase(GetCmdTail)) > 0 then
case CurPage of
wpWelcome, wpLicense, wpPassword, wpInfoBefore, wpUserInfo,
wpSelectDir, wpSelectProgramGroup, wpInfoAfter:
Result := True;
end;
end;
// ****************************************************************************
// Name: ApachePathParent
// Purpose: Returns the path of Apache parent folder.
function ApachePathParent(): String;
var
sApachePathParent: String;
iLengthString: Integer;
iPosK: Integer;
begin
if RegKeyExists(HKLM, REG_KEY_APACHE_SERVICE) and UsingWinNT then
begin
// Set g_sApachePathBin
RegQueryStringValue(HKLM, REG_KEY_APACHE_SERVICE,
'ImagePath', sApachePathParent);
// Remove the run command and strip quotes away from g_sApachePathBin
iPosK := Pos('-k', sApachePathParent);
iLengthString := Length(sApachePathParent);
Delete(sApachePathParent, iLengthString - (iLengthString - iPosK), iPosK);
sApachePathParent := RemoveQuotes(sApachePathParent);
// Strip basename twice so only the Apache parent path is left
sApachePathParent := ExtractFileDir(sApachePathParent);
sApachePathParent := ExtractFileDir(sApachePathParent);
end;
// Function variables
Result := sApachePathParent;
end;
// ****************************************************************************
// Name: ApacheTask
// Purpose: Decide if we should handle the Apache Server or not
function ApacheTask(): Boolean;
begin
Result:= UsingWinNT and not (ApachePathParent = '');
end;
// ****************************************************************************
// Name: ApacheBinFound
// Purpose: Checks if bin\apache.exe excists in Apache's parent folder .
// Returns True if Yes and False if No
function ApacheBinFound(): Boolean;
var
sApacheBinary: String;
begin
sApacheBinary := ApachePathParent() + '\bin\apache.exe';
if FileExists(sApacheBinary) then
begin
Result:= True;
end else begin
Result:= False;
end;
end;
// ****************************************************************************
// Name: ApacheServiceUninstall
// Purpose: Stopping and uninstalling the Apache Service
procedure ApacheServiceUninstall();
var
bRetVal: Boolean;
ErrorCode: Integer;
begin
// Stop and uninstall the Apache service
bRetVal := InstExec('cmd.exe', '/C apache -k stop', g_sApachePathBin,
True, False, SW_HIDE, ErrorCode);
bRetVal := InstExec('cmd.exe', '/C apache -k uninstall', g_sApachePathBin,
True, False, SW_HIDE, ErrorCode);
end;
// ****************************************************************************
// Name: ApacheServiceInstall
// Purpose: Installing and starting the Apache Service
procedure ApacheServiceInstall();
var
bRetVal: Boolean;
ErrorCode: Integer;
begin
// Install and start the Apache service
bRetVal := InstExec('cmd.exe', '/C apache -k install', g_sApachePathBin,
True, False, SW_HIDE, ErrorCode);
bRetVal := InstExec('cmd.exe', '/C apache -k start', g_sApachePathBin,
True, False, SW_HIDE, ErrorCode);
end;
// ****************************************************************************
// Name: ApacheModuleStatus
// Purpose: Identifying if a module is in a string and returning it's status
Function ApacheModuleStatus(sLine: String): Integer;
var
iStatus: Integer;
iPosSharp, iPosModule: Integer;
begin
iStatus:= STATUS_NONE;
iPosSharp := Pos('#', sLine);
iPosModule := Pos('LoadModule ', sLine);
if Pos('foo_module ', sLine) = 0 then
begin
if (iPosSharp > 0) and (iPosModule > iPosSharp) then
begin
iStatus := STATUS_DISABLED;
end else
begin
iStatus := STATUS_ENABLED;
end;
end;
Result := iStatus;
end;
// ****************************************************************************
// Name: ApacheModuleName
// Purpose: Extracting and returning a module name from a string
Function ApacheModuleName(sLine: String): String;
var
iPosModNameStart, iPosModNameEnd: Integer;
iCharNum: Integer;
sModuleName : String;
begin
iPosModNameStart := (Pos('modules/mod_', sLine) + 12);
iPosModNameEnd := (Pos('.so', sLine) - 1);
sModuleName := '';
iCharNum := iPosModNameStart;
for iCharNum := iPosModNameStart to iPosModNameEnd do
begin
sModuleName := sModuleName + StrGet(sLine, iCharNum);
end;
sModuleName := sModuleName + '_module';
Result := sModuleName;
end;
// ****************************************************************************
// Name: ApacheConfFileEdit
// Purpose: Checking if the httpd.conf (Subversion related modules) file
// if needed.
procedure ApacheConfFileEdit(aHttpdConf: TArrayOfString;
iPosFileModules, iPosFileModulesPost,
iPosModDav, iStatusModDav,
iPosModDavSvn, iStatusModDavSvn,
iPosModAuthzSvn, iStatusModAuthzSvn: Integer);
var
sConfFileName, sTimeString: String;
sLoadModDav, sLoadModDavSvn, sLoadModAuthzSvn: String;
begin
sConfFileName := g_sApachePathConf + '\httpd.conf';
sTimeString := GetDateTimeString('yyyy/mm/dd hh:mm:ss', '-', ':');
sLoadModDav := 'LoadModule dav_module modules/mod_dav.so';
sLoadModDavSvn := 'LoadModule dav_svn_module modules/mod_dav_svn.so';
sLoadModAuthzSvn := 'LoadModule authz_svn_module modules/mod_authz_svn.so';
//Backup the current httpd.conf
FileCopy (sConfFileName, sConfFileName + '-svn-' + sTimeString + '.bak', False);
// Add the modules if they're not there
if (iStatusModDav = STATUS_NONE) then
begin
if iPosModDav = 0 then
begin
iPosModDav := iPosFileModules + 10;
end;
aHttpdConf[iPosModDav] := aHttpdConf[iPosModDav] + #13#10 + sLoadModDav;
end;
if (iStatusModDavSvn = STATUS_NONE) then
aHttpdConf[iPosFileModulesPost -1] := aHttpdConf[iPosFileModulesPost -1] + #13#10 +
sLoadModDavSvn;
if (iStatusModAuthzSvn = STATUS_NONE) then
aHttpdConf[iPosFileModulesPost -1] := aHttpdConf[iPosFileModulesPost -1] + #13#10 +
sLoadModAuthzSvn;
// Enable modules if disabled ********************************
if (iStatusModDav = STATUS_DISABLED) then
aHttpdConf[iPosModDav] := sLoadModDav;
if (iStatusModDavSvn = STATUS_DISABLED) then
aHttpdConf[iPosModDavSvn] := sLoadModDavSvn;
if (iStatusModAuthzSvn = STATUS_DISABLED) then
aHttpdConf[iPosModAuthzSvn] := sLoadModAuthzSvn;
SaveStringsToFile(sConfFileName, aHttpdConf, False);
end;
// ****************************************************************************
// Name: ApacheConfFileHandle
// Purpose: Checking if the httpd.conf (Subversion related modules) file should
// be edited and sets some data for further proccessing if needed.
procedure ApacheConfFileHandle();
var
aHttpdConf : TArrayOfString;
sConfFileName: String;
sCurrentLine: String;
iLineNum, iArrayLen: Integer;
iPosFileModules, iPosFileModulesPost : Integer;
iPosModDav, iPosModDavSvn, iPosModAuthzSvn: Integer;
iStatusModDav, iStatusModDavSvn, iStatusModAuthzSvn: Integer;
begin
iStatusModDav := STATUS_NONE;
iStatusModDavSvn := STATUS_NONE;
iStatusModAuthzSvn := STATUS_NONE;
sConfFileName:= g_sApachePathConf + '\httpd.conf';
//Load the httpd.conf to the aHttpdConf array and init vars
LoadStringsFromFile(sConfFileName, aHttpdConf);
iArrayLen := GetArrayLength(aHttpdConf)-1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -