inno setup编程技术全图文教程!!!!
inno setup一个典型脚本
[Setup]
AppName=phpStudy
AppVerName=phpStudy 1.1.5 Build 070312
AppPublisher=phpshao
AppPublisherURL=http://phpshao.cublog.cn
AppSupportURL=http://phpshao.cublog.cn
AppUpdatesURL=http://phpshao.cublog.cn
DefaultDirName={pf}/phpStudy
DefaultGroupName=phpStudy
LicenseFile=aa/aaaa.rtf
;InfoAfterFile=D:/pro/aa/aaaa.rtf
VersionInfoCompany=phpshao
VersionInfoDescription=phpStudy 1.1.5 Build 070312
VersionInfoVersion=1.1.5.0
VersionInfoCopyright=Copyright (C) 2007 By phpshao
;OutputDir=E:/php
OutputBaseFilename=phpStudy5678
UninstallFilesDir={app}/uninst
WizardImageFile =aa.bmp
WizardSmallImageFile =bb.bmp
SetupIconFile=ss.ico
Compression=lzma
SolidCompression=true
[Languages]
Name: chinese; MessagesFile: compiler:Default.isl
Name: english; MessagesFile: compiler:Languages/English.isl
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}
[Files]
Source: www/phpinfo.php; DestDir: {code:GetDataDir}; Flags: ignoreversion;
.....................
[Types]
Name: "full"; Description: "完全安装"
Name: "custom"; Description: "自定义安装"; Flags: iscustom
[Components]
Name: "main"; Description: "ePSXe 1.6.0"; Types: full custom; Flags: fixed
Name: "bios"; Description: "BIOS"; Types: full custom
Name: "plugins"; Description: "插件"; Types: full custom
Name: "plugins/video"; Description: "视频插件"; Types: full custom
Name: "plugins/video/pete"; Description: "Pete's GPU 1.75"; Types: full custom
Name: "plugins/video/peops"; Description: "PE.Op.S Soft Driver 1.16"; Types: full custom
Name: "plugins/audio"; Description: "音频插件"; Types: full custom
Name: "plugins/audio/peopsa"; Description: "PE.Op.S Dsound Audio Driver 1.8"; Types: full custom
Name: "plugins/audio/eternal"; Description: "Eternal Spu 1.41"; Types: full custom
[INI]
Filename: {app}/phpshao.url; Section: InternetShortcut; Key: URL; String: http://blog.chinaunix.net/u/19869/
[Icons]
Name: {group}/readme; Filename: {app}/readme.html; Components: jb/ApachePHP
[UninstallDelete]
Type: files; Name: {app}/phpshao.url
Name: {app}/php5/session; Type: filesandordirs
Name: {app}/mysql5/data/ib*; Type: files; Components: jb/mysql5
Name: {app}/mysql5/data/*.err; Type: files; Components: jb/mysql5
[UninstallRun]
Filename: {app}/uninst/uninstalla.bat; WorkingDir: {app}/apache2/bin/; Components: jb/ApachePHP; StatusMsg: 正在卸载服务……
Filename: {app}/uninst/uninstallm.bat; WorkingDir: {app}/mysql5/bin/; Components: jb/mysql5; StatusMsg: 正在卸载服务……
[Messages]
BeveledLabel=phpStudy 1.1.5
[Code]
procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://phpshao.cublog.cn', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox(#13 'phpStudy 1.1.5' #13 #13'PHP开发集成包,无须配置即可使用!' #13#13 '版权所有(C) http://phpshao.cublog.cn', mbInformation, MB_OK);
end;
var
AboutButton, CancelButton: TButton;
DataDirPage: TInputDirWizardPage;
URLLabel: TNewStaticText;
LabelDate:Tlabel;
procedure InitializeWizard();
begin
{ Create the pages }
WizardForm.PAGENAMELABEL.Font.Color:= clred;
WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue;
WizardForm.WELCOMELABEL1.Font.Color:= clGreen;
WizardForm.WELCOMELABEL2.Font.Color:= clblack;
CancelButton := WizardForm.CancelButton;
AboutButton := TButton.Create(WizardForm);
AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
AboutButton.Top := CancelButton.Top;
AboutButton.Width := CancelButton.Width;
AboutButton.Height := CancelButton.Height;
AboutButton.Caption := '&About...';
AboutButton.OnClick := @AboutButtonOnClick;
AboutButton.Parent := WizardForm;
URLLabel := TNewStaticText.Create(WizardForm);
URLLabel.Caption := 'http://phpshao.cublog.cn';
URLLabel.Cursor := crHand;
URLLabel.OnClick := @URLLabelOnClick;
URLLabel.Parent := WizardForm;
{ Alter Font *after* setting Parent so the correct defaults are inherited first }
URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
URLLabel.Font.Color := clBlue;
URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
DataDirPage := CreateInputDirPage(wpSelectDir,
'选择PHP程序存放目录', '您想将你的PHP程序安装到何处?',
'您想将你的PHP程序安装到何处?'+#13#10 +'请选择不同的位置,键入新的路径,或单击“浏览”现有的文件夹。点击“继续”进入下一步。 '+#13#10,
False, '');
LabelDate:=Tlabel.Create(DataDirPage)
LabelDate.Caption:='欢迎进行PHP之旅!';
LabelDate.Left:=ScaleX(10);
LabelDate.Top:= ScaleY(150);
LabelDate.Font.Color:=$0000FF;
LabelDate.Font.Name:= '宋体';
LabelDate.Font.Size:= 16;
LabelDate.Font.Style:= [fsBold];
LabelDate.Parent = DataDirPage.Surface;
DataDirPage.Add('');
{ Set default values, using settings that were stored last time if possible }
DataDirPage.Values[0] := 'D:/www';
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo,
MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
S: String;
begin
{ Fill the 'Ready Memo' with the normal settings and the custom settings }
S := '';
S := S + MemoDirInfo + NewLine;
S := S + Space + DataDirPage.Values[0] + ' (PHP程序目录)' + NewLine+ NewLine;
S := S + MemoTypeInfo + NewLine+ NewLine;
S := S + MemoComponentsInfo + NewLine+ NewLine ;
S := S+ MemoGroupInfo + NewLine+ NewLine;
S := S + MemoTasksInfo + NewLine+ NewLine;
Result := S;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
IniFile, OldString, NewString,newstr,oldstr: string;
IniFileLines: TArrayOfString;
i: Integer;
ErrorCode: Integer;
begin
if CurStep = ssPostInstall then
begin
//WizardForm.InstallingPage.
OldString:='{adir}'; // 要替换的旧字符串
NewString:= ExpandConstant('{}'); // 新字符串
StringChange(NewString, '/', '/');
IniFile:= ExpandConstant('{app}/apache2/conf/httpd.conf'); // 你的 INI 文件名
newstr:= ExpandConstant('{code:GetDataDir}');
oldstr:='{appweb}';
LoadStringsFromFile(IniFile, IniFileLines);
for i:= 0 to GetArrayLength(IniFileLines)-1 do
begin
if (Pos(OldString, IniFileLines[i]) > 0) then
StringChange(IniFileLines[i], OldString, NewString);
end;
for i:= 0 to GetArrayLength(IniFileLines)-1 do
begin
if (Pos(oldstr, IniFileLines[i]) > 0) then
StringChange(IniFileLines[i], oldstr, newstr);
end;
SaveStringsToFile(IniFile, IniFileLines, False);
IniFile:= ExpandConstant('php.ini'); // 你的 INI 文件名
LoadStringsFromFile(IniFile, IniFileLines);
for i:= 0 to GetArrayLength(IniFileLines)-1 do
begin
if (Pos(OldString, IniFileLines[i]) > 0) then
StringChange(IniFileLines[i], OldString, NewString);
end;
SaveStringsToFile(IniFile, IniFileLines, False);
if IsComponentSelected('jb/mysql5') then
begin
IniFile:= ExpandConstant('{app}/MySQL5/my.ini');; // 你的 INI 文件名
LoadStringsFromFile(IniFile, IniFileLines);
for i:= 0 to GetArrayLength(IniFileLines)-1 do begin
if (Pos(OldString, IniFileLines[i]) > 0) then
StringChange(IniFileLines[i], OldString, NewString);
end;
SaveStringsToFile(IniFile, IniFileLines, False);
IniFile:= ExpandConstant('{win}/my.ini'); // 你的 INI 文件名
LoadStringsFromFile(IniFile, IniFileLines);
for i:= 0 to GetArrayLength(IniFileLines)-1 do begin
if (Pos(OldString, IniFileLines[i]) > 0) then
StringChange(IniFileLines[i], OldString, NewString);
end;
SaveStringsToFile(IniFile, IniFileLines, False);
ShellExec('open', ExpandConstant('{tmp}/installmysql.bat'), '', ExpandConstant('{app}/mysql5/bin'), SW_SHOW, ewnoWait, ErrorCode);
end;
WizardForm.StatusLabel.Font.Color:=$0000FF;
WizardForm.StatusLabel.Caption := '正在注册、启动服务,请稍等……';
ShellExec('open', ExpandConstant('{tmp}/installapache.bat'), '', ExpandConstant('{app}/apache2/bin'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
end;
end;
function GetDataDir(Param: String): String;
begin
{ Return the selected DataDir }
Result := DataDirPage.Values[0];
end;