inno setup工具使用总结
1、在打包脚本中修改某个票配置文件方法:
举例:通过语言选择修改配置文件中的参数Langtype
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
languageName: string;
begin
if CurStep=ssDone then //软件安装后执行
begin
languageName := ActiveLanguage(); // 获取用户选择的语言
if 'chinesesimplified' = languageName then
begin
SetIniString('LANGUAGE','Langtype','2',ExpandConstant('{app}/Settings/Config/config.dat'));
end
else if 'english' = languageName then
begin
SetIniString('LANGUAGE','Langtype','1',ExpandConstant('{app}/Settings/Config/config.dat'));
end;
end;
end;
配置文件内容config.dat
[LANGUAGE]
Total=24
Langtype=1
2、
inno setup打包时,卸载前关闭正在运行程序方法,以窗口名称来退出程序。
// 卸载时判断客户端是否正在运行
function InitializeUninstall(): Boolean;
var ErrorCode: Integer;
var IsRunning: HWND;
begin
Result :=true; //安装程序继续
IsRunning:=FindWindowByWindowName('xxx xxx');//xxx xxx为窗口名称
if(IsRunning<>0)then
begin
if Msgbox('卸载程序检测到软件正在运行。' #13#13 '您是否继续卸载单击“是”继续卸载,或按“否”退出!', mbConfirmation, MB_YESNO) = idYES then
begin
PostMessage(IsRunning, 18, 0, 0); // quit
IsRunning:=FindWindowByWindowName('xxx xxx');
end
else
begin
end;
end;
end;
//----------卸载驱动,完成后删除相关目录----------
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usDone then
begin
//删除 {app} 文件夹及其中所有文件
DelTree(ExpandConstant('{app}'), True, True, True);
DelTree(ExpandConstant('{commonappdata}\xx'), True, True, True);//需要清除的文件夹名
end;
end;