曾经在网上看到有网友问:
我用Setup Factory 8.0制作的安装程序,在执行安装的时候会有默认的安装路径,同时用户也可以选择安装路径。
比如默认的安装路径是 C:/Program Files/MyApp/
用户选择路径的D:/Program Files/
继续安装的话就会直接安装到D:/Program Files/,通常这个目录下很多其他文件,一不小心就会造成误操作把文件都安装到D:/Program Files/了。
能不能自动补全上MyApp?怎么做?
后来我也遇到这种问题,查看了Setup Factory的帮助文档,找到了解决的办法。只需要在Setup Factory目录下找到全局函数文件 _SUF70_Global_Functions.lua ,用记事本打开并查找g_EditFieldFolderBrowse,代码很简单,把这个函数改为如下:
function g_EditFieldFolderBrowse(nIDEditField, strPrompt)
-- get the current properties of the edit field
local tbEditProps = DlgEditField.GetProperties(nIDEditField);
if(not tbEditProps) then
-- The edit field is not accessible or does not exist
return;
end
-- display a folder browse dialog, using the current contents of the edit
-- field as the initial folder path (the folder to start browsing from)
local strInitialFolder = tbEditProps.Text;
local strTargetFolder = Dialog.FolderBrowse(strPrompt, strInitialFolder);
if((strTargetFolder == "") or (strTargetFolder == "CANCEL")) then
return;
end
-- replace the contents of the edit field with the folder path that was selected
--修改的内容,添加程序文件夹
strCCCn = SessionVar.Expand("%ProductName%");
tbEditProps.Text = strTargetFolder.."//"..strCCCn;
tbEditProps.Text = String.Replace(tbEditProps.Text, "", "//", false);
tbEditProps.Text = String.Replace(tbEditProps.Text, "//"..strCCCn.."//"..strCCCn, "//"..strCCCn, false);
--去掉重复的文件夹
DlgEditField.SetProperties(nIDEditField, tbEditProps);
end
如此简单就解决了,主要是这些语言完全不懂,费了很多时间。
再后来不用Setup Factory 了,因为发现了比它压缩率高n多的Inno Setup,脚本很是灵活,用好Pascal的话太强大了!