WriteProfInt

InstallShield 2020 » InstallScript Language Reference

Tip:All INI file changes should be created in the INI Files view of the IDE. Handling all of your INI file changes in this way allows for a clean uninstallation through the Windows Installer service.

The WriteProfInt function modifies an .ini file by inserting or updating a profile string that assigns an integer value to a key. Note the following important points:

Because of the way in which Windows caches file changes, you should flush the cache buffer after calls to WriteProfString.
Changes made to .ini files can be logged for uninstallation.
To write a string value to an .ini file, call WriteProfString instead.
Use the AddProfString and ReplaceProfString functions when you want to modify the System.ini file.

Syntax

WriteProfInt ( szFileName, szSectionName, szKeyName, iValue );

Parameters

WriteProfInt Parameters

Parameter

Description

szFileName

Specifies the name of the .ini file. If the file name is unqualified (that is, if a drive designation and path are not included), InstallShield searches for the file in the Windows folder. If the file does not exist, it is created in the specified folder; if a path is not included in file name, the file is created in the Windows folder. Note that if the file name is qualified with a path that does not exist, WriteProfInt will fail.

szSectionName

Specifies the name of the .ini file section in which szKeyName will be inserted or modified. The section name should not be enclosed within delimiting brackets ( [ ] ). The search for this name is not case sensitive.

szKeyName

Specifies the unique key to be updated. If a key that is to be updated does not exist in the specified section, it is created.

Note:To delete an entire section from an .ini file, pass a null string ("") in szKeyName. To delete one or more keys from a section in an .ini file, use WriteProfString.

iValue

Specifies an integer value to assign to the unique key identified by szKeyName.

Return Values

WriteProfInt Return Values

Return Value

Description

0

Indicates that the function successfully updated the specified .ini file.

< 0

Indicates that the function was unable to update the specified .ini file.

Additional Information

The WriteProfInt function uses the Windows API WritePrivateProfileString to access the .ini file. Therefore, its functionality is limited by the functionality provided by the Windows API. Consult Microsoft documentation for more information on .ini files.
Windows 95 and later cache .ini files, which can cause a delay in writing changes to the specified files. This in turn can interfere with subsequent file operations, such as calls to CopyFile and XCopyFile. Therefore, you should flush the cache buffer after using WriteProfInt if you are using file operations shortly afterward. Simply call WriteProfInt with null parameters to force Windows 95 or later to write the data to the .ini file immediately, as shown below:

WriteProfInt ("c:\\Test.ini", "Windows", "KeyboardDelay", 100);    WriteProfInt ("", "", "", 0); // null string in first three parameters    //CopyFile should now have access to updated file.    CopyFile ("c:\\test.ini", "d:\\test.ini");

See Also