WriteProfileString

  BOOL WriteProfileString(lpszSection, lpszEntry, lpszString)    
  LPCTSTR lpszSection; /* address of section name */
  LPCTSTR lpszEntry; /* address of entry name */
  LPCTSTR lpszString; /* address of string to write */

The WriteProfileString function copies a string into the specified section of the Windows initialization file, WIN.INI.

Parameters

lpszSection

Points to a null-terminated string that specifies the section to which the string is to be copied. If the section does not exist, it is created. The name of the section is case-independent; the string may be any combination of uppercase and lowercase letters.

lpszEntry

Points to the null-terminated string containing the entry to be associated with the string. If the entry does not exist in the specified section, it is created. If this parameter is NULL, the entire section, including all entries within the section, is deleted.

lpszString

Points to the null-terminated string to be written to the file. If this parameter is NULL, the entry specified by the lpszEntry parameter is deleted.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

Windows keeps a cached version of WIN.INI to improve performance. If all three parameters are NULL, Windows flushes the cache.

Sections in the WIN.INI initialization file have the following form:

[section]
entry=string
.
.
.

The WriteProfileString function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

GetProfileString, WritePrivateProfileString