从Inno Pascal设置DestDir? [英] Setting DestDir from Inno Pascal?
问题描述
我想将文件安装在不同的文件夹中,具体取决于用户是选择为所有用户安装还是仅为当前用户安装.
I want to install files in different folders, depending on whether the user has selected to install for all users or just the current user.
我添加了CreateInputOptionPage()来创建带有两个单选按钮的选项页.
I have added used CreateInputOptionPage() to create an option page with two radio buttons.
但是,我的安装程序现在到处都是重复的行,就像这两行一样:
However, my installer is now littered with lots of duplicate lines, like these two:
Source: {#ProjectRootFolder}\License.txt; DestDir: {userdocs}\{#MyAppName}; Check: NOT IsAllUsers
Source: {#ProjectRootFolder}\License.txt; DestDir: {commondocs}\{#MyAppName}; Check:IsAllUsers
是否有更优雅的方法可以完成上述操作?例如,Pascal代码可以创建像#define这样的变量吗,这样我可以代替上面的{userdocs}和{commondocs}使用它吗?
Is there a more elegant way to do the above? Can Pascal code, for example, create a variable like #define does so I can use it in place of {userdocs} and {commondocs} above?
更多详细信息:
上面的IsAllUsers()函数调用此代码:
The IsAllUsers() function above calls this code:
function IsAllUsers: Boolean;
begin
#ifdef UPDATE
Result := AllUsersInRegistryIsTRUE;
#else
Result := AllUsersOrCurrentUserPage.Values[1]; // wizard page second radio button
#endif
end;
和:
function AllUsersInRegistryIsTRUE: Boolean; // True if preceding install was to all users' documents
var
AllUsersRegValue: AnsiString;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'Software\MyApp', 'AllUsers', AllUsersRegValue) then
Result := (UpperCase(AllUsersRegValue) = 'YES')
else
Result := FALSE;
end;
推荐答案
这样的衣服会适合吗?
[Files]
Source: {#ProjectRootFolder}\License.txt; DestDir: {code:GetDir}\{#MyAppName};
...
[Code]
var
OptionsPage: TInputOptionWizardPage;
procedure InitializeWizard;
begin
OptionsPage := CreateInputOptionPage(wpUserInfo,
'please select', 'the kind of installation', 'and continue..',
True, False);
OptionsPage.Add('All users');
OptionsPage.Values[0] := True;
OptionsPage.Add('This user');
end;
function GetDir(Dummy: string): string;
begin
if OptionsPage.Values[0] then
Result := ExpandConstant('{commondocs}')
else
Result := ExpandConstant('{userdocs}');
end;
这篇关于从Inno Pascal设置DestDir?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!