Вопрос Как считать выбранные компоненты и записать их в реестр в виде значения (ValueData:)...

AlexS

Новичок
Всем привет, нужна помощь в решении одного вопроса...
Нужно записать выбранные компоненты (их описание) в значение (ValueData) ключа реестра.
Записываться данные должны в строчку через точку с запятой, перед первым и после последнего значения точка с запятой не должна ставиться...
Для ясности прилагаю пример...
code_language.pascal:
[Setup]
AppName=My Program
AppVersion=1.5
DisableWelcomePage=yes
DisableProgramGroupPage=yes
CreateUninstallRegKey=no
CreateAppDir=no
Uninstallable=no
OutputDir=userdocs:Inno Setup Examples Output

[Types]
Name: "full"; Description: "Полная установка";
Name: "compact"; Description: "Компактная установка";
Name: "custom"; Description: "Выборочная установка"; Flags: iscustom;

[Components]
Name: "Component1"; Description: "Comp1"; Types: full custom;
Name: "Component2"; Description: "Comp2"; Types: full compact;
Name: "Component3"; Description: "Comp3"; Types: full compact;
Name: "Component4"; Description: "Comp4"; Types: full custom;
Name: "Component5"; Description: "Comp5"; Types: full custom;
                              
[Registry]
// ValueData: "Comp1;Comp2;Comp3;Comp4;Comp5" - Здесь данные должны ситываться из кода: ValueData: {code:...};
Root: HKCR; SubKey: *\Shell\TestReg; ValueType: string; ValueName: SubCommands; ValueData: "Comp1;Comp2;Comp3;Comp4;Comp5"; Flags: uninsdeletevalue uninsdeletekeyifempty

[Code]
procedure CheckCompSelected();

var
  I: Integer;
  RegCompName: string;
begin
  begin
    for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
    begin
      if WizardForm.ComponentsList.Checked[I] then
      begin
        // В "RegCompName" содержатся данные выбранных компонентов, их нужно зписать в значение ключа реестра в строчку
        // через точку с запятой(перед первым и после последнего значения точка с запятой быть не должна)...
        RegCompName := WizardForm.ComponentsList.Items[I];
        MsgBox(RegCompName, mbInformation, MB_OK);
      end;
    end;
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
 case CurPageID of
  10:
  begin
    CheckCompSelected();
  end;
 end;
end;
 

Andreo Fadio

Старожил
@AlexS, как то так:
Код:
procedure CheckCompSelected();

var
  I: Integer;
  RegCompName, RGCName, RGCmini: string;
begin
   RGCName:= '';
    for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
    begin
      if WizardForm.ComponentsList.Checked[I] then
      begin
        RegCompName := WizardForm.ComponentsList.Items[I];
      If RGCName <> '' then RGCmini:= ';';
       RGCName:= RGCName + RGCmini + RegCompName;
      end;
    end;
  if RGCName <> '' then
  RegWriteStringValue(HKCR,'*\Shell\TestReg','SubCommands',RGCName);
end;


А из этой секции убрать.
 

AlexS

Новичок
Отлично... Всё работает как надо. Большое спасибо!
А из этой секции убрать.
Решил оставить, сделал так...
code_language.pascal:
[Setup]
AppName=My Program
AppVersion=1.5
DisableWelcomePage=yes
DisableProgramGroupPage=yes
CreateUninstallRegKey=no
CreateAppDir=no
Uninstallable=no
OutputDir=userdocs:Inno Setup Examples Output

[Types]
Name: "full"; Description: "Полная установка";
Name: "compact"; Description: "Компактная установка";
Name: "custom"; Description: "Выборочная установка"; Flags: iscustom;

[Components]
Name: "Component1"; Description: "Comp1"; Types: full custom;
Name: "Component2"; Description: "Comp2"; Types: full compact;
Name: "Component3"; Description: "Comp3"; Types: full compact;
Name: "Component4"; Description: "Comp4"; Types: full custom;
Name: "Component5"; Description: "Comp5"; Types: full custom;

[Registry]
Root: HKCR; SubKey: *\Shell\TestReg; ValueType: string; ValueName: SubCommands; ValueData: {code:GetRegValue}; Flags: uninsdeletevalue uninsdeletekeyifempty

[Code]
var
  I: Integer;
  RegCompName, RGCName, RGCmini, RegCompValue: string;

procedure CheckCompSelected();
begin
   RGCName:= '';
    for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
    begin
      if WizardForm.ComponentsList.Checked[I] then
      begin
        RegCompName := WizardForm.ComponentsList.Items[I];
      If RGCName <> '' then RGCmini:= ';';
       RGCName:= RGCName + RGCmini + RegCompName;
      end;
    end;
  if RGCName <> '' then
  RegCompValue := RGCName;
end;

function GetRegValue(Param: String): string;
begin
  CheckCompSelected();
  Result := RegCompValue;
end;
 
Последнее редактирование:

Andreo Fadio

Старожил
@AlexS, можно меньше:
Код:
[Setup]
AppName=My Program
AppVersion=1.5
DisableWelcomePage=yes
DisableProgramGroupPage=yes
CreateUninstallRegKey=no
CreateAppDir=no
Uninstallable=no
OutputDir=userdocs:Inno Setup Examples Output

[Types]
Name: "full"; Description: "Полная установка";
Name: "compact"; Description: "Компактная установка";
Name: "custom"; Description: "Выборочная установка"; Flags: iscustom;

[Components]
Name: "Component1"; Description: "Comp1"; Types: full custom;
Name: "Component2"; Description: "Comp2"; Types: full compact;
Name: "Component3"; Description: "Comp3"; Types: full compact;
Name: "Component4"; Description: "Comp4"; Types: full custom;
Name: "Component5"; Description: "Comp5"; Types: full custom;

[Registry]
Root: HKCR; SubKey: *\Shell\TestReg; ValueType: string; ValueName: SubCommands; ValueData: {code:GetRegValue}; Flags: uninsdeletevalue uninsdeletekeyifempty

[Code]
function GetRegValue(Param: String): string;
var
  I: Integer;
  RegCompName, RGCName, RGCmini: string;
begin
   RGCName:= '';
    for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
    begin
      if WizardForm.ComponentsList.Checked[I] then
      begin
        RegCompName := WizardForm.ComponentsList.Items[I];
      If RGCName <> '' then RGCmini:= ';';
       RGCName:= RGCName + RGCmini + RegCompName;
      end;
    end;
  if RGCName <> '' then
  Result := RGCName else Result := '';
end;
 
Сверху