BOOL WritePrivateProfileSection(lpszSection, lpszKeysAndValues, lpszFile) | |||
LPCTSTR lpszSection; | |||
LPCTSTR lpszKeysAndValues; | |||
LPCTSTR lpszFile; |
This function replaces the entire contents of the application section in the specified initialization file, as named by the lpszSection parameter, with the key name, value pairs specified in the lpszKeysAndValues parameter.
If there is no matching application section name, then this functions creates the section at the end of the specified initialization file and initializes the new section with the key name and value pairs specified in the lpszKeysAndValues parameter.
lpszSection
Points to a null-terminated character string that names the application.
lpszKeysAndValues
Points to the buffer that contains the new key name and value pairs associated to be written to the named application section.
lpszFile
Points to a null-terminated character string that names the initialization file. If lpszFile does not contain a fully qualified pathname for the file, this function searches the Windows directory for the file. If the file does not exist and lpszFile does not contain a fully qualified pathname, this function creates the file in the Windows directory. The function does not create a file if lpszFile contains the fully qualified pathname of a file that does not exist.
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.
The format of the key name, value pairs in the lpszKeysAndValues buffer, is one or more null terminated strings, terminated by the final null character. Each string has the following format:
KeyName=Value
WritePrivateProfileSection is not case-dependent, so the strings in lpszSection may be in any combination of uppercase and lowercase letters.
This operation deletes all of the existing key name and value pairs for the named application section and then inserts the new key name and value pairs contained in the lpszKeysAndValues buffer. No attempt is made to correlate old and new key names, so if the new names appear in a different order than the old key names, then any comment lines in the section will be probably be associated with the wrong key name, value pairs.
This operation is atomic, in that no other reads or writes to the specified initialization file are allowed while the key name, value pairs for the application section are being written.
The WritePrivateProfileSection 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).
GetPrivateProfileSection, GetPrivateProfileInt, GetPrivateProfileString, GetProfileSection, GetProfileInt, GetProfileString, WritePrivateProfileString, WriteProfileString, WriteProfileSection