0

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 ;)

Community
  • 1
  • 1

1 Answers1

0

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.

Community
  • 1
  • 1
RobeN
  • 5,346
  • 1
  • 33
  • 50
  • That serial page is a script for multiple edits. It's not intended to be used for anything else than for what it was written. But if you still decide to use it, then you can make a single purpose scripted constant getter which will return the result of my `GetSerialNumber` function call. Or modify the `GetSerialNumber` function to match the scripted constant prototype. Writing to registry before the installation is not fair to the user. – TLama Jan 22 '14 at 13:27
  • I used the CheckSerial (UserInfoPage) funktion now. Is it possible, that there is already a code filled in the box and the user can change it? – Michael Jan 22 '14 at 15:05
  • @Michael, for that you can specify value for the [`DefaultUserInfoSerial`](http://www.jrsoftware.org/ishelp/index.php?topic=setup_defaultuserinfoserial) directive. – TLama Jan 22 '14 at 15:09
  • Hours of searching and such a simple solution... Thank you very very much, now everything works perfekt :) – Michael Jan 22 '14 at 15:17