緣由:使用inno setup 生成的現有自動生成的卸載程序不能清理守護進程、更新進程、注冊表等相關信息,造成信息殘留,一定程度上影響安全性。
inno setup 生成的現有自動生成的卸載程序:
Why the uninstaller EXE has numbers in its name
Frequently new users wonder why the uninstaller EXE has numbers in its name (e.g. unins000.exe).
It is because Inno Setup allows multiple applications to be installed to the same directory. When that happens, the first application's uninstaller is named unins000.exe, the second application's uninstaller is named unins001.exe, and so on. If a fixed name were used, then it would only be possible to uninstall the most recently installed application.

卸載時刪除注冊表
在[Code]段添加如下代碼:
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
if MsgBox('您是否要刪除注冊信息?', mbConfirmation, MB_YESNO) = IDYES then
RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER, 'Software\My Prog')
end;
使用時請將代碼中紅色部分替換為實際要保留的注冊表信息。
如果想要 卸載時詢問是否保留注冊信息,可以把代碼中藍色部分改為 IDNO。
如果想要刪除 文件或文件夾 ,可使用以下代碼:
//刪除 {app} 文件夾中的My Prog.exe
DeleteFile(ExpandConstant('{app}\My Prog.exe'));
//刪除 {app} 文件夾及其中所有文件
DelTree(ExpandConstant('{app}'), True, True, True);
//刪除 {app} 文件夾中的所有文件,但保留它本身
DelTree(ExpandConstant('{app}'), False, True, True);
//刪除程序運行時的信息(整個目錄刪除)
function RegDeleteKeyIncludingSubkeys(const RootKey: Integer; const SubkeyName: String): Boolean;
//刪除自啟動信息
function RegDeleteValue(const RootKey: Integer; const SubKeyName, ValueName: String): Boolean;
