Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert the contents of AppID in [setup] into a string in [code]?

Tags:

inno-setup

When I use the INNO wizard I get an *.iss file that contains in its setup section:

[Setup]
AppId={87E1AD40-F32B-4EF7-A2FF-5B508814068A}

<statements not included here}

I then add a procedure in the code section for the generation of an *.ini file to be used as input to my application. The code section contains the following:

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
 // Purpose: write an *.ini file
 //    Used as input to the program to be executed
 var
   S: string;
 begin
   if CurStep = ssPostInstall then
   begin
     //* Output language entered
     S := Format('[%s]'+#13#10, ['LANGUAGE']);
     SaveStringToFile(ExpandConstant('{app}\UserInputs.ini'), S, False);
     S := Format('language = %s'+#13#10, [ActiveLanguage]);
     SaveStringToFile(ExpandConstant('{app}\UserInputs.ini'), S, True);      

     <code not included here>

     //* Output AppId code generated by INNO
     S := Format('[%s]'+#13#10, ['REGISTRATION']);  // key word
     SaveStringToFile(ExpandConstant('{app}\UserInputs.ini'), S, True);
     // S := Format(??)
     //SaveStringToFile(ExpandConstant('{app}\UserInputs.ini'), S, True);
  end;
end;

How can I Format AppId so that S will contain "87E1AD40-F32B-4EF7-A2FF-5B508814068A" [i.e., S := Format(??)]?

like image 948
Birdy40 Avatar asked Nov 16 '13 17:11

Birdy40


1 Answers

If you want to expand certain [Setup] section setting in your code, you can use the SetupSetting preprocessor function. In your question you've mentioned you want to get the AppId directive value, which you've set to a GUID value including {} chars, which you want to have stripped on your output. The following script shows how to get the AppId directive value and how to copy just the part without those enclosing {} chars:

[Setup]
AppId={{87E1AD40-F32B-4EF7-A2FF-5B508814068A}
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program

[Code]
procedure InitializeWizard;
var
  S: string;
begin
  S := '{#SetupSetting("AppId")}';
  S := Copy(S, 3, Length(S) - 3);
  MsgBox(S, mbInformation, MB_OK);
end;
like image 112
TLama Avatar answered Oct 13 '22 06:10

TLama