使用上一个目录向导中的目录

时间:2019-03-31 09:14:58

标签: inno-setup

我需要在注册表中设置一些路径来存储数据文件。  我要求具有某些DirWizard页面的用户选择一个文件夹。我首先从注册表中填充值(如果它们存在的话),否则我想根据用户在上一页中输入的目录+子文件夹为用户提供默认值。

但是看起来我使用的{code:GetDatadir|0}常量没有填充用户输入的内容,而是在您输入安装目录后设置的?

我想要的。

  • 第1页:安装目录(wpSelectDir)(C:\ App)
  • 第2页:自定义目录向导(第1页答案+子文件夹)(C:\ App \ Datadir)
  • 第3页:自定义目录向导(第2页答案+子文件夹(C:\ App \ Datadir \ folder 1)

代码变得很长,我不喜欢Pascal。希望有人能向我指出正确的方向,以重新使用文件夹填充下一页中的字段以及我在做什么错。

[Code]
var
  DBMAMInputQueryPage: TInputQueryWizardPage;
  TSInputQueryPage: TInputQueryWizardPage;
  DataDirPage: TInputDirWizardPage;
  SupportFilesDirPage: TInputDirWizardPage;
  SupportFilesDirPage2: TInputDirWizardPage;

 function GetDataDirPath(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App', 'DataDirectory', ResultStr)
       then
          Result := ResultStr
       else
          Result := WizardDirValue + '\DataDir';
    end;

 function GetSupportFolder1(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder1', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder1' )
    end;

function GetSupportFolder2(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder2', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder2' )
    end;

function GetSupportFolder3(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder3', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder3' )
    end;

function GetSupportFolder4(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder4', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder4' )
    end;

function GetSupportFolder5(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder5', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder5' )
    end;

function GetSupportFolder6(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder6', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder6' )
    end;

function GetSupportFolder7(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder7', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder7' )
    end;

function GetSupportFolder8(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder8', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder8' )
    end;

function GetSupportFolder9(Param: String): String;
 var ResultStr: String;
    begin
       if RegQueryStringValue( HKEY_CURRENT_USER, 'Software\App\Supportfolders', 'SupportFolder9', ResultStr)
       then
          Result := ResultStr
       else
          Result := ExpandConstant( '{code:GetDatadir|0}\SupportFolder9' )
    end;

function GetDataDir(Param: String): String;
  begin
    Result := DataDirPage.Values[StrToInt(Param)];
  end;

function GetSupportFilesDir(Param: String): String;
  begin
    Result := SupportFilesDirPage.Values[StrToInt(Param)];
  end;

function GetSupportFilesDir2(Param: String): String;
  begin
    Result := SupportFilesDirPage2.Values[StrToInt(Param)];
  end;



procedure InitializeWizard;
begin
  { create a directory input page }
  DataDirPage := CreateInputDirPage(wpSelectDir,
  'Data Directory settings', 'subcaption',
  'Select data dir', 
  False, 'New Folder');
  { add directory input page items }
  DataDirPage.Add('Data Directory destination folder'); 
  { assign default directories for the items from the previously stored data; if }
  { there are no data stored from the previous installation, use default folders }
  { of your choice }
  DataDirPage.Values[0] := ExpandConstant('{code:GetDataDirPath}');

  { create a directory input page }
  SupportFilesDirPage := CreateInputDirPage(DataDirPage.ID,
  'Support Files Directory settings', 'DataDir paths',
  'Select where your support files should be stored. Will be read from registry if exist.', 
  False, 'New Folder');
  { add directory input page items }
  SupportFilesDirPage.Add('Supportfolder1');
  SupportFilesDirPage.Add('Supportfolder2'); 
  SupportFilesDirPage.Add('Supportfolder3'); 
  SupportFilesDirPage.Add('Supportfolder4'); 

  { assign default directories for the items from the previously stored data; if }
  { there are no data stored from the previous installation, use default folders }
  { of your choice }
  SupportFilesDirPage.Values[0] := ExpandConstant('{code:GetSupportFolder1}');
  SupportFilesDirPage.Values[1] := ExpandConstant('{code:GetSupportFolder2}');
  SupportFilesDirPage.Values[2] := ExpandConstant('{code:GetSupportFolder3}');
  SupportFilesDirPage.Values[3] := ExpandConstant('{code:GetSupportFolder4}');

  { create a directory input page }
  SupportFilesDirPage2 := CreateInputDirPage(SupportFilesDirPage.ID,
  'Support Files Directory settings', 'DataDir paths',
  'Select where your support files should be stored. Will be read from registry if exist.', 
  False, 'New Folder');
  SupportFilesDirPage2.Add('Supportfolder5'); 
  SupportFilesDirPage2.Add('Supportfolder6');
  SupportFilesDirPage2.Add('Supportfolder7'); 
  SupportFilesDirPage2.Add('Supportfolder8');
  SupportFilesDirPage2.Add('Supportfolder9');

  { assign default directories for the items from the previously stored data; if }
  { there are no data stored from the previous installation, use default folders }
  { of your choice }
  SupportFilesDirPage2.Values[0] := ExpandConstant('{code:GetSupportFolder5}');
  SupportFilesDirPage2.Values[1] := ExpandConstant('{code:GetSupportFolder6}');
  SupportFilesDirPage2.Values[2] := ExpandConstant('{code:GetSupportFolder7}');
  SupportFilesDirPage2.Values[3] := ExpandConstant('{code:GetSupportFolder8}');
  SupportFilesDirPage2.Values[4] := ExpandConstant('{code:GetSupportFolder9}');
end;

0 个答案:

没有答案