Inno Setup 5制作安装程序
1.想到的時候填寫安裝目錄
C:\Program Files (x86)\云曜互聯
最后效果:
C:\Program Files (x86)\云曜互聯\后宮OL
?
2.打開網頁:
[CODE]
procedure CurStepChanged(CurStep:TSetupStep);
var
ErrorCode: Integer;
begin
if CurStep=ssDone then ShellExec('open','http://www.houg.cn ', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
?
3.安裝向導圖標:
WizardImageFile=embedded\WizardImage.bmp
WizardSmallImageFile=embedded\WizardSmallImage.bmp
?
4.桌面快捷方式:
[Tasks]
Name:"desktopicon"; Description: "{cm:CreateDesktopIcon}";GroupDescription: "{cm:AdditionalIcons}"; Flags: checkedonce
Name:"quicklaunchicon"; Description:"{cm:CreateQuickLaunchIcon}"; GroupDescription:"{cm:AdditionalIcons}"; Flags: checkedonce
?
5.不允許卸載
[Setup]
Uninstallable=no? 這個屬性不會生成安裝文件
?
6.不允許寫注冊表
?? [Setup]???????? CreateUninstallRegKey=no? 這個屬性適用于更新程序或者安裝子程序
5. 程序卸載
;添加卸載文件
;[UninstallDelete]
;Type: files; Name:"{win}\MYPROG.INI"
或者寫函數
?
刪清安裝目錄及下文件:
[CODE]
//卸載過程?
procedureCurUninstallStepChanged (CurUninstallStep: TUninstallStep );
var
position:Integer;
begin
???? if CurUninstallStep=usDone
???? then
???? //查詢當前目錄,防止錯誤的刪除
???? position:= Pos('后宮OL',ExtractFilePath(ExpandConstant('{uninstallexe}')));
???? if(0 <> position) then
???? begin
???? DelTree(ExpandConstant('{app}'), FALSE,TRUE, TRUE);
???? end
????
???? //刪清注冊表
???? if RegKeyExists(HKEY_CURRENT_USER,'Software\GamePlatform') then
???? begin
????RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER,'Software\GamePlatform');
???? end
end;
自定義卸載文件名
[CODE]
//安裝過程
procedure CurStepChanged(CurStep:TSetupStep);
var
uninspath, uninsname, NewUninsName,MyAppName: string;
begin
if CurStep=ssDone then
begin
?
//指定新的卸載文件名(不包含擴展名)
NewUninsName := '卸載后宮';
//應用程序名稱,與 [SEUTP]段的AppName必須一致
MyAppName := '后宮OL';
?
//以下重命名卸載文件
uninspath:= ExtractFilePath(ExpandConstant('{uninstallexe}'));
uninsname:=Copy(ExtractFileName(ExpandConstant('{uninstallexe}')),1,8);
RenameFile(uninspath + uninsname + '.exe',uninspath + NewUninsName + '.exe');
RenameFile(uninspath + uninsname + '.dat',uninspath + NewUninsName + '.dat');
?
//更新卸載的快捷方式
if(FileExists('C:\ProgramData\Microsoft\Windows\StartMenu\Programs\后宮OL\卸載后宮OL.lnk')) then
begin
DeleteFile('C:\ProgramData\Microsoft\Windows\StartMenu\Programs\后宮OL\卸載后宮OL.lnk');
CreateShellLink(
?ExpandConstant('C:\ProgramData\Microsoft\Windows\Start Menu\Programs\后宮OL\卸載后宮OL.lnk'),
? '快捷方式',
?ExpandConstant('{app}\卸載后宮.exe'),
?ExpandConstant(''),
?ExpandConstant('{app}'),
? '',
? 0,
?SW_SHOWNORMAL);
end
?
end
end; ?
6.注冊表操作
;不能選擇安裝路徑,安裝路徑從注冊表讀取
DefaultDirName={reg:HKCU\Software\HougGame\Plaza,Path}
?
自選擇安裝目錄之后要寫入注冊表:
[Registry]
Root: HKCU; Subkey:"Software\Microsoft\Windows NT\CurrentVersion\Drivers32"; ValueName:"msacm.eqa"; ValueType: String; ValueData: "audio.acm";Flags: createvalueifdoesntexist uninsdeletevalue deletevalue
Root: HKCU; Subkey:"Software\Microsoft\Windows NT\CurrentVersion\Drivers32"; ValueName:"vidc.MVE4"; ValueType: String; ValueData: "video.dll";Flags: createvalueifdoesntexist uninsdeletevalue deletevalue
Root: HKLM; Subkey:"Software\Microsoft\Windows NT\CurrentVersion\Drivers32"; ValueName:"msacm.eqa"; ValueType: String; ValueData: "audio.acm";Flags: createvalueifdoesntexist uninsdeletevalue deletevalue
Root: HKLM; Subkey:"Software\Microsoft\Windows NT\CurrentVersion\Drivers32"; ValueName:"vidc.MVE4"; ValueType: String; ValueData: "video.dll";Flags: createvalueifdoesntexist uninsdeletevalue deletevalue
Root: HKCU; Subkey:"Software\HougGame\Plaza"; ValueName: "Path"; ValueType:String; ValueData: "{app}"; Flags: createvalueifdoesntexist uninsdeletevaluedeletevalue
Root: HKCU; Subkey:"Software\HougGame"; Flags: uninsdeletekey
?
7.安裝完成后,更新游戲列表
procedure CurStepChanged(CurStep:TSetupStep);
var
?hWnd: HWND;
?
begin
???if CurStep=ssDone?? then
?????begin
???????hWnd := FindWindowByClassName('GamePlaza');
?
???????if hWnd <> 0 then
?????????begin
????????????? PostMessage(hWnd, 1124, 100, 0);
????????????? //MessageBox(0,'PostMessage(hWnd, 1124, 5, 0);', 'MessageBox', MB_OK);
?????????end
????end
end;
?[Setup]
;不允許用戶自定義文件夾
DisableDirPage=yes
[Icons]
;開始欄卸載
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
;控制面板不生成卸載項
CreateUninstallRegKey=no
;控制面板卸載圖標
UninstallDisplayIcon={app}/HougGame.exe
總結
以上是生活随笔為你收集整理的Inno Setup 5制作安装程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VC使用flash简易教程
- 下一篇: 引用传参和指针传参