使用Inno Setup卸载过程中删除文件夹时出现问题 [英] Problems in deleting a Folder during the uninstallation with Inno Setup
问题描述
我首先说我是使用Inno设置的新手,如果这是一个愚蠢的问题,我感到抱歉. 我正在尝试在卸载应用程序时删除包含所有子文件夹和文件的文件夹.首次运行应用程序时,将在我的文档"中创建特定的文件夹.要删除它,我正在使用"Delltree"功能:
I begin by saying that i am new in using Inno setup and i am sorry if this is a dumb question. I am trying to delete a folder with all it's sub-folders and files during the uninstallation of an application. The specific folder is created in My Documents when the application runes for the first time. For deleting it i am using the "Delltree" function:
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var Ceva: integer;
begin
case CurUninstallStep of
usUninstall:
begin
MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall is about to start.', mbInformation, MB_OK)
end;
usPostUninstall:
begin
Ceva := MsgBox('CurUninstallStepChanged:' #13#13 'Do you want to delete the folder ?.', mbConfirmation, MB_YESNO)
if Ceva = idYES then
DelTree('{userdocs}\myfolder', True, True, True);
end;
end;
由于某些原因,"{userdocs}"常量似乎无法正常工作.如果我将确切路径放在文件夹"DelTree('C:\ Users \ myuser \ Documents \ myfolder',True,True,True);"下,一切正常.
For some reason the "{userdocs}" constant appear not to be working. If i put the exact path to the folder "DelTree('C:\Users\myuser\Documents\myfolder', True, True, True); " everything is working fine.
推荐答案
在代码中使用常量时,需要使用ExpandConstant函数.因此,您的Deltree命令应为:
When you use a constant in code, you need to use the ExpandConstant function. So your Deltree command should be:
DelTree('ExpandConstant({userdocs})\ myfolder', 真,真,真);
DelTree('ExpandConstant({userdocs})\myfolder', True, True, True);
或者,您是否看过[UninstallDelete]部分?它可以在卸载时删除目录和文件,而无需代码.
Alternatively, have you looked at the [UninstallDelete] section? It can delete a directory and files at uninstall time without the need for code.
这篇关于使用Inno Setup卸载过程中删除文件夹时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!