Inno Setup Inputbox for serialcode with output into the registry

457 Views Asked by At

I used the code from this Answer from the Member TLama. I think it's exactly what i need, but I have two problems with it:

I need the Serial from the edit boxes in the registry. This is what i tried:

Root: "HKCU"; Subkey: "Software\myProg"; ValueType: string; ValueName: "Serial"; ValueData: "{code:GetSerialNumber}"; Flags: deletevalue uninsdeletevalue

but Inno gives me an error. TLama wrote in his answer (from the Link above), it's enought to call the GetSerialNumber part, but I do sth. wrong...

The other question: Is it possible to prefill the serialbox with an example code? E.g. 12345 or abcde? I'm using only one input box with 10 chars...

Hope someone can help, and sorry for my bad english ;)

1

There are 1 best solutions below

4
On

You can use UserInfoPage and then {userinfoserial} but if you want to use TLama's solution then you should slightly change NextButtonClick function:

function NextButtonClick(CurPageID: Integer): Boolean;
var
  S: string;
  I: Integer;
begin
  Result := True;
  if CurPageID = SerialPage.ID then
  begin
    S := '';
    for I := 0 to High(SerialEdits) do
      S := S + SerialEdits[I].Text + '-';
      SetLength(S, Length(S)-1);
   RegWriteStringValue(HKEY_CURRENT_USER, 'Software\myProg',
    'Serial', S);
  end;
end;

Var SerialEdits: array of TEdit; has to be set as Global for the script. You also may want to add key to registry later (e.g. with CurStepChanged when ssDone or something) or write your own function that will pass Serial to Result as String and then call it in Registry Section.