Version Introduced: ODBC 2.0
SQLWritePrivateProfileString writes a value name and data to the Odbc.ini subkey of the system information.
[Input] Points to a null-terminated string containing the name of the section to which the string will be copied. If the section does not exist, it is created. The name of the section is case-independent; the string can be any combination of uppercase and lowercase letters.
[Input] Points to a null-terminated string containing the name of the key to be associated with a string. If the key does not exist in the specified section, it is created. If this argument is NULL, the entire section, including all entries within the section, is deleted.
[Input] Points to a null-terminated string to be written to the file. If this argument is NULL, the key pointed to by the lpszEntry argument is deleted.
[Output] Points to a null-terminated string that names the initialization file.
The function returns TRUE if it is successful, FALSE if it fails.
When SQLWritePrivateProfileString returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.
General installer error
An error occurred for which there was no specific installer error.
The requested system information could not be written.
Out of memory
The installer could not perform the function because of a lack of memory.
SQLWritePrivateProfileString is provided as a simple way to port drivers and driver setup DLLs from Microsoft® Windows® to Microsoft Windows NT®/Windows 2000. Calls to WritePrivateProfileString that write a profile string to the Odbc.ini file should be replaced with calls to SQLWritePrivateProfileString. SQLWritePrivateProfileString calls functions in the Win32® API to add the specified value name and data to the Odbc.ini subkey of the system information.
A configuration mode indicates where the Odbc.ini entry listing DSN values is in the system information. If the DSN is a User DSN (the state variable is USERDSN_ONLY), the function writes to the Odbc.ini entry in HKEY_CURRENT_USER. If the DSN is a System DSN (SYSTEMDSN_ONLY), the function writes to the Odbc.ini entry in HKEY_LOCAL_MACHINE. If the state variable is BOTHDSN, HKEY_CURRENT_USER is tried, and if it fails, HKEY_LOCAL_MACHINE is used.