from:http://www.caodi.name/blog/innosetup_manual.html
一.关于Inno Setup如何在安装时播放音乐
方法(1):
在脚本编译里的[Co
de]与[Files]段处添加以下代码:
[Co
de]
Function mciSendString(lpszCommand: String; lpszReturnString: Integer; cchReturnLength: Integer; hwndCallback: Integer): Integer;
external 'mciSendStringA@winmm.dll stdcall';
Function mciSendString(lpszCommand: String; lpszReturnString: Integer; cchReturnLength: Integer; hwndCallback: Integer): Integer;
external 'mciSendStringA@winmm.dll stdcall';
procedure InitializeWizard();
var
BGMusicFile, SplashFile: string;
SplashForm: TForm;
SplashFileName: String;
I: Integer;
begin
ExtractTemporaryFile(ExtractFileName(ExpandConstant(' {tmp} \music.mp3')));
SplashForm := TForm.create(nil);
with SplashForm do
begin
mciSendString(ExpandConstant('play {tmp} \music.mp3'),0,0,0);
Close;
Free;
end;
end;
[Files]
Source: " C:\music.mp3"; Flags: dontcopy
Source: " C:\music.mp3"; Flags: dontcopy
或者
Source: "
C:\mymusic.mp3"; DestDir: "{tmp}";
Flags: dontcopy
代码说明:[Co de]中蓝色代码
{tmp}与
\music.mp3的意思是播放inno setup安装时创建的临时文件夹内的music.mp3音乐文件!
[Files]中
C:\music.mp3
是你音乐源文件的地址,填自己的音频名称与音频格式。Flags: dontcopy 的意思是在
安装时将音乐文件放到Inno Setup所创建的临时文件夹内,并且在完成安装后删除此音乐文件!
二.关于Inno Setup如何修改安装向导内的图片
这个很简单,只需来到Inno Setup程序的根目录找到
WizModernSmallImage.BMP 与
WizModernImage.bmp 这个2个图片文件替换即可。
其中:WizModernImage.bmp
为左侧图 如图(1); WizModernSmallImage.BMP则为右上角图标 如图(2)。
说明:WizModernImage.bmp这个图片的大小为:164×314 WizModernSmallImage.BMP这个图片的大小为:55×55 (这2个图片大小 我是按照以前默认大小改的,其它比例大小我没试过,有兴趣的话可以自己试下。)
![Inno Setup详细教程(转载) - pony - pony的博客](http://www.caodi.name/upload/2011/5/201105272030442807.jpg)
![Inno Setup详细教程(转载) - pony - pony的博客](http://www.caodi.name/upload/2011/5/201105272030442058.jpg)
三:关于Inno Setup如何在安装分割线里加入文字 如图:
![Inno Setup详细教程(转载) - pony - pony的博客](http://www.caodi.name/upload/2011/5/201105272030444204.jpg)
只需要加入一个[Messages]段并在此段下输入以下代码:
BeveledLabel=Professional
BeveledLabel=Professional
代码说明:
其中绿色部分Professional为自定义文字,可以自行随意输入!
四:关于Inno Setup如何创建多个桌面快捷方式
这个也是很简单只要在[Icons]段加入以下代码:
Name: "{commondesktop}\程序名称1"; Filename: "{app}\InstVise.exe"; Tasks: desktopicon;
WorkingDir: "{app}"
Name: "{commondesktop}\程序名称2"; Filename: "{app}\Translator.exe"; Tasks: desktopicon; WorkingDir: "{app}"
说明:程序名称1 and 程序名称2 就是快捷方式的名字,这个自己定义。InstVise.exe and Translator.exe为快捷方式位于根目录的源执行文件。(还有值得注意的是,如果你一开始选择的是使用向导来创建安装并且在向导快捷方式项目已经对是否创建桌面快捷方式进行了打勾,那么系统会自动在[Icons]段自动创建主执行文件的快捷方式,此代码为:Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 这条代码中{#MyAppName}的意思是使用安装文件夹内主执行文件的程序名字,{#MyAppExeName}的意思是安装文件夹内主执行文件的源执行文件名称。请大家注意的是避免重复建立快捷方式。如果想用这段代码请在后面添加绿色部分;WorkingDir: "{app}"这个是快捷方式的起始位置。在默认情况下没有这部分。可能会导致快捷方式无法打开!)
09.08.26更新增加(有些游戏或者软件的主执行文件不在安装目录内而在安装目录的子文件内,像这种情况的解决方法如下):
测试修正中!
-----------------------------------------------------------------------------------------------------------
Name: "{commondesktop}\
快捷方式程序名称"; Filename: "
{app}\qq.exe"; Tasks: desktopicon;
WorkingDir: "{app}"
说明:
其中蓝色字部分是要注意的:
1.
{app}\qq.exe
将进行子目录添加,如:{app}\子文件夹1\子文件夹2\qq.exe
2.{app}
将进行对应添加,如:{
app}\子文件夹1\子文件夹2\
-----------------------------------------------------------------------------------------------------------
五:关于Inno Setup安装欢迎界面文字与安装向导文字颜色修改
我们只需创建[Co de]段在此段添加如下代码:
[Co de]
//千万别忘记我噢~~
procedure InitializeWizard();
begin
//改变欢迎页面文字的颜色 (如图)
WizardForm.WelcomeLabel1.Font.Color:=
clNavy;
WizardForm.WelcomeLabel2.Font.Color:=
clTeal;
![Inno Setup详细教程(转载) - pony - pony的博客](http://www.caodi.name/upload/2011/5/201105272030445635.jpg)
//改变其他页面文字的颜色 (如图)
WizardForm.PageNameLabel.Font.Color:=
clred;
WizardForm.PageDescriptionLabel.Font.Color:=
clBlue;
end;
![Inno Setup详细教程(转载) - pony - pony的博客](http://www.caodi.name/upload/2011/5/201105272030447261.jpg)
说明:代码中浅绿色标识的为颜色,可以随意替换目前只发现支持以下颜色!
-----------------------------------------------------------------------------------------------------------
clBlack(黑色),clMaroon(暗红),clGreen(绿色),clOlive(橄榄绿),
clNavy(深蓝),clPurple(紫色),clTeal(深青),clGray(灰色),
clSilver(浅灰),clRed(红色),clLime(浅绿),clYellow(黄色),
clBlue (蓝色),clFuchsia(紫红),clAqua(青绿),clWhite(白色)。
clNavy(深蓝),clPurple(紫色),clTeal(深青),clGray(灰色),
clSilver(浅灰),clRed(红色),clLime(浅绿),clYellow(黄色),
clBlue (蓝色),clFuchsia(紫红),clAqua(青绿),clWhite(白色)。
-----------------------------------------------------------------------------------------------------------
六:Inno Setup的打包压缩与分割压缩bin文件的方法
1.分割bin文件,在
[setup]段添加:
DiskSpanning=true
DiskSliceSize=2100000000
DiskSliceSize=2100000000
说明:DiskSliceSize=2100000000 是按字节计算,可随意输入想分割的数。貌似最多不能超过2200000000
2.Inno Setup的压缩格式,默认是按照7Z的压缩算法进行压缩的。还是在
[setup]段:
找到:Compression=
lzma
说明:其中绿色的lzma为默认压缩格式,也就是7z的默认压缩方式进行压缩。下面在提供一种实用
的压缩方式,也就是7z的极限压缩。
-----------------------------------------------------------------------------------------------------------
Compression=none(此命令为不压缩。)
Compression=
lzma/ultra64
(此压缩为7z极限压缩算法,耗内存很大时间也会长些。不过压缩率很不错!)
-----------------------------------------------------------------------------------------------------------
七.关于Inno Setup在安装欢迎界面时添加自己的文字方法(如图)
![Inno Setup详细教程(转载) - pony - pony的博客](http://www.caodi.name/upload/2011/5/201105272030441858.jpg)
方法(1):
1.添加[Co
de]段
2.在此段下输入以下代码:
procedure InitializeWizard();
var
LabelDate: Tlabel;
begin
WizardForm.WelcomeLabel2.Autosize := true;
LabelDate := Tlabel.Create(WizardForm);
LabelDate.Autosize := true;
LabelDate.Caption :=
'本程序由Professional制作'#10#13#10#13'欢迎PC爱好者共同讨论'#10#13#10#13'Professional: upload/2011/5/201105272030447154.jpg" />
添加[Co
de]段,在此段下输入代码:
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox('欢迎访问Professional'#13#13'http://hi.baidu.com/pfia', mbInformation, mb_Ok);
end;
begin
MsgBox('欢迎访问Professional'#13#13'http://hi.baidu.com/pfia', mbInformation, mb_Ok);
end;
procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://hi.baidu.com/pfia', '', '', SW_SHOW, ewNoWait, ErrorCode)
end;
end;
procedure InitializeWizard();
var
AboutButton: TButton;
URLLabel: TNewStaticText;
var
AboutButton: TButton;
URLLabel: TNewStaticText;
begin
AboutButton := TButton.Create(WizardForm);
AboutButton.Left := WizardForm.ClientWidth - WizardForm.CancelButton.Left - WizardForm.CancelButton.Width;
AboutButton.Top := WizardForm.CancelButton.Top;
AboutButton.Width := WizardForm.CancelButton.Width;
AboutButton.Height := WizardForm.CancelButton.Height;
AboutButton.Caption := '关于(&A)';
AboutButton.On Click := @AboutButtonOnClick;
AboutButton.Parent := WizardForm;
AboutButton := TButton.Create(WizardForm);
AboutButton.Left := WizardForm.ClientWidth - WizardForm.CancelButton.Left - WizardForm.CancelButton.Width;
AboutButton.Top := WizardForm.CancelButton.Top;
AboutButton.Width := WizardForm.CancelButton.Width;
AboutButton.Height := WizardForm.CancelButton.Height;
AboutButton.Caption := '关于(&A)';
AboutButton.On
AboutButton.Parent := WizardForm;
URLLabel := TNewStaticText.Create(WizardForm);
URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
URLLabel.Left := AboutButton.Left + AboutButton.Width + 10;
URLLabel.Caption := 'Professional';
URLLabel.Font.Style := [fsBold, fsUnderline];
URLLabel.Font.Color := clBlue;
URLLabel.Cursor := crHand;
URLLabel.On Click := @URLLabelOnClick;
URLLabel.Font.Name := '宋体';
URLLabel.Font.Height := ScaleY(-13);
URLLabel.Parent := WizardForm;
URLLabel.Hint := '点击访问相关网站';
URLLabel.ShowHint := True;
end;
URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
URLLabel.Left := AboutButton.Left + AboutButton.Width + 10;
URLLabel.Caption := 'Professional';
URLLabel.Font.Style := [fsBold, fsUnderline];
URLLabel.Font.Color := clBlue;
URLLabel.Cursor := crHand;
URLLabel.On
URLLabel.Font.Name := '宋体';
URLLabel.Font.Height := ScaleY(-13);
URLLabel.Parent := WizardForm;
URLLabel.Hint := '点击访问相关网站';
URLLabel.ShowHint := True;
end;
代码说明:
①:
绿色代码部分是点击关于按钮后弹出的信息,#13为换行符。
②:
紫色代码部分是点击超链接信息后转到的网站地址。
③:
粉色代码部分为关于按钮的名称,(&A)为快捷键,可随意填写字母。
④:
蓝色代码部分为超链接文字名称。
⑤:
黄色代码部分为超链接文字名称颜色,
clBlue 可改为其它颜色。如:
clBlack(黑色),clMaroon(暗红),clGreen(绿色),clOlive(橄榄绿),
clNavy(深蓝),clPurple(紫色),clTeal(深青),clGray(灰色),
clSilver(浅灰),clRed(红色),clLime(浅绿),clYellow(黄色),
clBlue (蓝色),clFuchsia(紫红),clAqua(青绿),clWhite(白色)。
clNavy(深蓝),clPurple(紫色),clTeal(深青),clGray(灰色),
clSilver(浅灰),clRed(红色),clLime(浅绿),clYellow(黄色),
clBlue (蓝色),clFuchsia(紫红),clAqua(青绿),clWhite(白色)。
⑥:红色代码部分为超链接文字名称字体,可修改为黑体字型等。
⑦:橙色代码部分为鼠标指针放到超链接文字标题上显示的提示语。