我为我的一些游戏创建了一个安装程序,我希望卸载程序能够询问我是否要保存我的游戏文件. 这样的事情:当我执行uninstall.exe问我’你想保留所有保存的游戏吗?’是还是不是.如果我
这样的事情:当我执行uninstall.exe问我’你想保留所有保存的游戏吗?’是还是不是.如果我点击YES,我的保存文件将保留,我的程序文件将被卸载,如果我点击NO我的程序文件包含保存文件将被卸载.
InnoSetup的PASCAL代码是做什么的?
非常感谢你!
你可以这样做:; -- UninstallCodeExample1.iss -- ; ; This script shows various things you can achieve using a [Code] section for Uninstall [Setup] AppName=My Program AppVerName=My Program version 1.5 DefaultDirName={pf}\My Program DefaultGroupName=My Program UninstallDisplayIcon={app}\MyProg.exe OutputDir=userdocs:Inno Setup Examples Output[Files] Source: "MyProg.exe"; DestDir: "{app}" Source: "MyProg.chm"; DestDir: "{app}" Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme[Code] function InitializeUninstall(): Boolean; begin Result := MsgBox('InitializeUninstall:' #13#13 'Uninstall is initializing. Do you really want to start Uninstall?', mbConfirmation, MB_YESNO) = idYes; if Result = False then MsgBox('InitializeUninstall:' #13#13 'Ok, bye bye.', mbInformation, MB_OK); end;procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); var mRes : integer; begin case CurUninstallStep of usUninstall: begin mRes := MsgBox('Do you want to remove all files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2) if mRes = IDYES then begin MsgBox ('Really remove the files', mbInformation, MB_OK) DeleteFile('path\filename.ext'); End else MsgBox ('Don''t remove the game files', mbInformation, MB_OK); // ...insert code to perform pre-uninstall tasks here... end; end; end;
您可能希望使用最新版本的InnoSetup,就像我测试的那样.上面的示例基于InnoSetup编译器附带的UninstallCodeExample.iss.
我添加了一行代码来说明如何删除文件.它调用DeleteFile函数.您需要为卸载时要删除的每个文件添加一个DeleteFile,该文件不在[Files]部分中.