Reading Data from .ini Files

InstallShield 2023

Project:This information applies to the following project types:

• Basic MSI
• DIM
• InstallScript MSI
• Merge Module
• MSI Database
• MSM Database
• Transform

You can use the GetProfString function to read data (such as key names) from an .ini file, regardless of where the .ini file is located (for example, on a network). The following example script provides a guide:

/*

 

Assuming the .ini file is called Test.ini, and contains the following:

 

[ProductSettings]

Key1=One

Key2=2

Key3=III

Key4=....

 

[OtherSettings]

Key1=Value1

Key2=Value2

 

*/

 

function OnBegin( )

    STRING svKey1Value; // filled in by GetProfString

begin

 

// read a single value

GetProfString(

    "\\\\Server\\Config\\Test.ini", // file name; note the double

backslash for each "real" backslash

    "ProductSettings", // section name without square brackets

    "Key1", // key name

    svKey1Value); // STRING variable to capture key value

 

MessageBox("Key1's value is: " + svKey1Value, INFORMATION);

 

end;

See Also