WritePrivateProfileString Function

Declare Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long

WritePrivateProfileString sets a value inside of any INI file. This function can also be used to set numerical values if they are in string form, for example using "1". If the INI file you try to write to does not exist, it will be created. Likewise, if the section or value does not exist, it will also be created. The function returns 0 if an error occurs, or a non-zero value if successful.

lpApplicationName
The section of the INI file to write to.
lpKeyName
The name of the value to set.
lpString
The string to set as the value.
lpFileName
The filename of the INI file to write to.

Example:

' Set the "StatusBar" setting in the [Options]
'  section of "C:\MyApps\dummy.ini"
x = WritePrivateProfileString("Options", "StatusBar", "1", "C:\MyApps\dummy.ini")

Related Calls: GetPrivateProfileString, WriteProfileString
Category: INI Files
Back to the index.


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/writeprivateprofilestring.html