Function Windows API Class

WritePrivateProfileString

Writes a Key Name and Value pair into a Windows Private Profile (INI) file.

Signature (Visual Basic / VBA)

Public Function WritePrivateProfileString( _
      Optional ByVal vKeyName As Variant _
    , Optional ByVal vValue As Variant _
    , Optional ByVal vSectionName As Variant _
    , Optional ByVal vFileName As Variant _
    ) As Boolean

Code Example

    Assuming
       Dim estWAPI As New WindowsAPI
       estWAPI.ProfileFileName = "Sample.Ini"
       estWAPI.ProfileSectionName = "Sample Section"
    for example
       estWAPI.WritePrivateProfileString("Convert From", "5 kilometers") = True

Parameters

Parameter Description
vKeyName Name of the String setting whose value is to be written. Function returns Null if vKeyName is Null or cannot be fixed-up to a String.
vValue The string Value that will be associated with the Name vKeyName. If vValue is Null, the Setting (Name and Value pair) with Name vKeyName will be removed. vValue defaults to Null if it is missing or Null or cannot be fixed-up to a string.
vSectionName The Section Name into which the Setting will be written. vSectionName defaults to the current value of the ProfileSectionName Property if it is missing or Null or cannot be fixed-up to a String.
vFileName The name of the Private Profile (INI) File into which the Setting will be written. vFileName defaults to the current value of the ProfileFileName Property if it is missing or Null or cannot be fixed-up to a String.

Notes & Version History

v1.3 Change Removed 16-bit support from this function.