原文博客在这个连接:https://blog.youkuaiyun.com/galaxyjs/article/details/4157131
但是这个博客的东西有一丢丢小问题,
(1)一个就是反斜杠的方向反了,
(2)另一个就是你直接粘贴上述博客。可能会有格式问题导致的空格多余的问题,会导致编不过,注意粘贴完之后去掉多余空格。
截图看下我编过的版本:
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_1%");
tbEditProps.Text = strTargetFolder.."\\"..strCCCn;
tbEditProps.Text = String.Replace(tbEditProps.Text,"\\\\", "\\",false);
tbEditProps.Text = String.Replace(tbEditProps.Text,strCCCn,strCCCn,false);
--去掉重复的文件夹
DlgEditField.SetProperties(nIDEditField,tbEditProps);
end