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(??)]?
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With