Version Introduced: ODBC 3.0
SQLWriteFileDSN writes information to a File DSN.
[Input] Pointer to the name of the File DSN. A DSN extension is appended to all file names that do not already have a DSN extension.
[Input] Pointer to the name of the application. This is "ODBC" for the ODBC section.
[Input] Pointer to the name of the key to be read. See "Comments" for reserved keywords.
[Output] Pointed to the string associated with the key to be written. The maximum length of the string pointed to by this argument is 32,767 bytes.
The function returns TRUE if it is successful, FALSE if it fails.
When SQLWriteFileDSN 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.
Invalid install path
The path of the file name specified in the lpszFileName argument was invalid.
Invalid type of request
The lpszAppName, lpszKeyName, or lpszString argument was NULL.
ODBC reserves the section name [ODBC] in which to store the connection information. The reserved keywords for this section are the same as those reserved for a connect string in SQLDriverConnect. (For more information, see the SQLDriverConnect function description.)
Applications can use these reserved keywords to write information directly to a File DSN. If an application wants to create or modify the DSN-less connection string associated with a File DSN, it can call SQLWriteFileDSN for any of the reserved connection string keywords in the [ODBC] section.
If the lpszString argument is a null pointer, the keyword pointed to by the lpszKeyName argument will be deleted from the .dsn file. If the lpszString and lpszKeyName arguments are both null pointers, the section pointed to by the lpszAppName argument will be deleted from the .dsn file.