Source: "C:\Example\原始文件\log\*"; DestDir: "{app}\log"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
;安装类型设置
[Types]
Name: Full ;Description:"完全安装"; Flags: iscustom
Name: Compact ;Description:"简洁安装";
Name: Custom; Description:"自定义安装";
;组件安装
[Components]
Name: c1; Description: "自定义任务3" ; Types: Full
Name: a1; Description: "安装Components_1"; Types: Full Compact Custom ;
Name: a2; Description: "安装Components_2"; Types : Full Compact
Name: a3; Description: "安装Components_3"; Types : Full
;开始菜单,桌面快捷方式
[Icons]
Name: "{group}\ISsample"; Filename: "{app}\ISsample.exe"
Name: "{group}\{cm:ProgramOnTheWeb,ISsample}"; Filename: "http://zwkufo.blog.163.com"
Name: "{group}\{cm:UninstallProgram,ISsample}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: quicklaunchicon
;添加一个帮助文挡
Name: {group}\ISsample 1.0.0.0 帮助文档;Filename: {app}\ISsample.chm
;用来在程序安装完成后 在安装程序显示最终对话框之前执行程序 常用与运行主程序 显示自述文件 删除临时文件
[Run]
Filename: "{app}\ISsample.exe"; Description: "{cm:LaunchProgram,ISsample}"; Flags: nowait postinstall skipifsilent
Filename: "{app}\ISsample.txt"; Description: "查看显示自述文件"; Flags: postinstall skipifsilent shellexec
;更改显示在程序中显示的消息文本
[Messages]
BeveledLabel=HKiss科技
;卸载对话框说明
ConfirmUninstall=您真的想要从电脑中卸载ISsample吗?%n%n按 [是] 则完全删除 %1 以及它的所有组件;%n按 [否]则让软件继续留在您的电脑上.
;定义解压说明
;StatusExtractFiles=解压并复制主程序文件及相关库文件...
;用于在用户系统中创建,修改或删除ini文件健值
[INI]
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Flags: uninsdeletesection
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server ip"; String: "127.0.0.1"
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server port"; String: "8080"
;用于在用户系统中创建,修改或删除注册表健值
[Registry]
Root: HKLM ;SubKey:"Software\ISsample";ValueType:dword;ValueName:config;ValueData:10 ;Flags:uninsdeletevalue
;在执行脚本
[code]
//全局变量
var MyProgChecked: Boolean;
//判断程序是否存在
//初始华程序事件
function InitializeSetup(): boolean;
var Isbl: boolean; //声明变量
var Isstr: string;
begin //开始
Isbl := true; //变量赋值
Isstr := '欢迎';
if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\ISsample', 'config') then
begin
MsgBox('已安装过,请先卸载在安装',mbConfirmation, MB_OK);
isbl := false;
end else
begin
//MsgBox('无值',mbConfirmation, MB_OK);
isbl := true;
end;
//下面是个麻烦的 条件语句 end else 注意
//if MsgBox(Isstr, mbConfirmation, MB_OKCANCEL) = IDOK then
//begin
// isbl := true;
// MsgBox('执行了', mbConfirmation, MB_OK);
//end else
//begin
// isbl := false;
//MsgBox('执行了', mbConfirmation, MB_OK);
//end;
Result := Isbl;
end; //结束
procedure CurStepChanged(CurStep: TSetupStep);
var Isstr :string;
begin
if CurStep=ssInstall then //实际安装前调用
begin
//MsgBox('CurStepChanged:实际安装前调用', mbConfirmation, MB_OKCANCEL); //安装完成后调用
end;
if CurStep=ssPostInstall then
begin
Isstr := ExpandConstant('{tmp}\tmp.rar');
// if FileExists(Isstr) then
// begin
// MsgBox('文件存在',mbConfirmation, MB_OK);
// end else
// begin
// MsgBox('文件不存在',mbConfirmation, MB_OK);
// end;
// MsgBox('CurStepChanged:实际安装后调用', mbConfirmation, MB_OKCANCEL);
end;
end;
//下一步 按钮按钮 事件
function NextButtonClick(CurPageID: Integer): Boolean;
var ResultCode: Integer;
var IsSetup : Boolean;
begin
IsSetup := true ;
case CurPageID of
wpSelectDir:
MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardDirValue + '''.', mbInformation, MB_OK); //WizardDirValue路径
wpSelectProgramGroup:
MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardGroupValue + '''.', mbInformation, MB_OK); //开始菜单名
wpReady:
begin
if not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Test', 'config') then begin
if MsgBox('程序执行需要Test.ext,是否安装!', mbConfirmation, MB_YESNO) = idYes then begin
ExtractTemporaryFile('test.exe');
if not Exec(ExpandConstant('{tmp}\test.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
MsgBox('Test.exe出错:' #13#13 ' ' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK);
end else begin
IsSetup := false ;
end ;
BringToFrontAndRestore();
end;
end;
end;
Result := IsSetup;
end;
修改文件某行
procedure test2();
var
fileName,tempStr:String;
svArray: TArrayOfString;
nLines,i:Integer;
begin
fileName := ExpandConstant('{app}\Apache\conf\httpd.conf');
LoadStringsFromFile(fileName, svArray);
nLines := GetArrayLength(svArray);
for i := 0 to nLines - 1 do
begin
tempStr := svArray[i];
if (1 = Pos('ServerRoot', tempStr)) then //Pos函数,判断当前行是否含有'ServerRoot'子串,返回1表示在1的位置找到子串,若不能找到该子串返回0
begin
svArray[i] := ExpandConstant('ServerRoot "{app}\Apache\"'); //修改开头是'ServerRoot'那行文本,此时只是修改内存数据的内容,并未写入文件
StringChangeEx(svArray[i], '\', '/', True); //StringChangeEx函数,将字符串中所有的符号\替换为符号/
end;
if (1 = Pos('Listen', tempStr)) then //找到端口配置行
svArray[i] := 'Listen 80'; //修改Apache端口号
if (1 = Pos('DocumentRoot', tempStr)) then
begin
svArray[i] := ExpandConstant('DocumentRoot "{app}\Apache\htdocs"');
StringChangeEx(svArray[i], '\', '/', True);
end;
if ((1 = Pos('<Directory', tempStr)) and (Pos('htdocs', tempStr) > 1)) then
begin
svArray[i] := ExpandConstant('<Directory "{app}\Apache\htdocs">');
StringChangeEx(svArray[i], '\', '/', True);
end;
end;
SaveStringsToFile(fileName, svArray, false); //最后从内存写回原文件,false表示不追加直接覆盖之前所有内容
end;
查看是否安装运行库
var
vcSP1Missing: Boolean;
function NeedInstallVCSP1(): Boolean;
begin
Result := vcSP1Missing;
end;
function InitializeSetup(): Boolean;
begin
vcSP1Missing := true;
if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{710f4c1c-cc18-4c49-8cbf-51240c89a1a2}')
then
begin
vcSP1Missing := false;
end;
result := true;
end;
- Visual C++ 2005 SP1 MFC Security Update Redistributable Package (x86) {710F4C1C-CC18-4C49-8CBF-51240C89A1A2}
- Visual C++ 2010 SP1 Redistributable Package (x86) {F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
软件是否运行
function IsAppRunning(const FileName : string): Boolean;
var
ProcessRunState :Integer;
begin
result := false;
Exec('cmd.exe', Format('/C tasklist|findstr /i %s',[FileName]), '', SW_HIDE,ewWaitUntilTerminated, ProcessRunState);
if (ProcessRunState = 0) then
begin
result := true;
end;
end;
修改背景图
WizardImageFile=myimage.bmp,myimage2.bmp
100% 164x314
125% 192x386
150% 246x459
175% 273x556
200% 328x604
225% 355x700
250% 410x797
WizardSmallImageFile=mysmallimage.bmp,mysmallimage2.bmp
100% 55x55
125% 64x68
150% 83x80
175% 92x97
200% 110x106
225% 119x123
250% 138x140
数字签名
https://jingyan.baidu.com/article/11c17a2c065713f446e39dc1.html
http://cicada.bajiaohuixiang.com/article/snapshot?id=92&type=clean
其他文档
Pascal Scripting: Support Functions Reference
inno setup读取注册表遇到的一个坑
64位操作系统读取注册表问题:
function GetInstallString(): String;
var
sInstallPath: String;
begin
sInstallPath := 'C:\Program Files\Adobe\Common\Plug-ins\7.0\MediaCore';
if RegValueExists(HKLM64, 'SOFTWARE\Adobe\Premiere Pro\CurrentVersion', 'Plug-InsDir') then
begin
RegQueryStringValue(HKLM64, 'SOFTWARE\Adobe\Premiere Pro\CurrentVersion', 'Plug-InsDir', sInstallPath)
end
Result := sInstallPath;
end;
NSIS 设置安装包exe属性中的详细信息
我们首先将安装界面的语言设置为简体中文 SimpChinese
; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"
; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"
VIProductVersion "${PRODUCT_VERSION}" ;版本号,格式为 X.X.X.X (若使用则本条必须)
VIAddVersionKey /LANG=${LANG_SimpChinese} "ProductName" "