2 * Implementation of the ODBC driver installer
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Hans Leidekker
6 * Copyright 2007 Bill Medland
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
34 #include "wine/heap.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(odbc
);
40 /* Registry key names */
41 static const WCHAR drivers_key
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C','\\','O','D','B','C','I','N','S','T','.','I','N','I','\\','O','D','B','C',' ','D','r','i','v','e','r','s',0};
42 static const WCHAR odbcW
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C',0};
43 static const WCHAR odbcini
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C','\\','O','D','B','C','I','N','S','T','.','I','N','I','\\',0};
44 static const WCHAR odbcdrivers
[] = {'O','D','B','C',' ','D','r','i','v','e','r','s',0};
45 static const WCHAR odbctranslators
[] = {'O','D','B','C',' ','T','r','a','n','s','l','a','t','o','r','s',0};
47 /* This config mode is known to be process-wide.
48 * MSDN documentation suggests that the value is hidden somewhere in the registry but I haven't found it yet.
49 * Although both the registry and the ODBC.ini files appear to be maintained together they are not maintained automatically through the registry's IniFileMapping.
51 static UWORD config_mode
= ODBC_BOTH_DSN
;
53 /* MSDN documentation suggests that the error subsystem handles errors 1 to 8
54 * only and experimentation (Windows 2000) shows that the errors are process-
55 * wide so go for the simple solution; static arrays.
57 static int num_errors
;
58 static int error_code
[8];
59 static const WCHAR
*error_msg
[8];
60 static const WCHAR odbc_error_general_err
[] = {'G','e','n','e','r','a','l',' ','e','r','r','o','r',0};
61 static const WCHAR odbc_error_invalid_buff_len
[] = {'I','n','v','a','l','i','d',' ','b','u','f','f','e','r',' ','l','e','n','g','t','h',0};
62 static const WCHAR odbc_error_component_not_found
[] = {'C','o','m','p','o','n','e','n','t',' ','n','o','t',' ','f','o','u','n','d',0};
63 static const WCHAR odbc_error_out_of_mem
[] = {'O','u','t',' ','o','f',' ','m','e','m','o','r','y',0};
64 static const WCHAR odbc_error_invalid_param_sequence
[] = {'I','n','v','a','l','i','d',' ','p','a','r','a','m','e','t','e','r',' ','s','e','q','u','e','n','c','e',0};
65 static const WCHAR odbc_error_invalid_param_string
[] = {'I','n','v','a','l','i','d',' ','p','a','r','a','m','e','t','e','r',' ','s','t','r','i','n','g',0};
66 static const WCHAR odbc_error_invalid_dsn
[] = {'I','n','v','a','l','i','d',' ','D','S','N',0};
67 static const WCHAR odbc_error_load_lib_failed
[] = {'L','o','a','d',' ','L','i','b','r','a','r','y',' ','F','a','i','l','e','d',0};
68 static const WCHAR odbc_error_request_failed
[] = {'R','e','q','u','e','s','t',' ','F','a','i','l','e','d',0};
69 static const WCHAR odbc_error_invalid_keyword
[] = {'I','n','v','a','l','i','d',' ','k','e','y','w','o','r','d',' ','v','a','l','u','e',0};
71 /* Push an error onto the error stack, taking care of ranges etc. */
72 static void push_error(int code
, LPCWSTR msg
)
74 if (num_errors
< sizeof error_code
/sizeof error_code
[0])
76 error_code
[num_errors
] = code
;
77 error_msg
[num_errors
] = msg
;
82 /* Clear the error stack */
83 static void clear_errors(void)
88 static inline WCHAR
*heap_strdupAtoW(const char *str
)
95 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
96 ret
= heap_alloc(len
*sizeof(WCHAR
));
98 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
105 BOOL WINAPI
ODBCCPlApplet( LONG i
, LONG j
, LONG
* p1
, LONG
* p2
)
108 FIXME( "( %d %d %p %p) : stub!\n", i
, j
, p1
, p2
);
112 static LPWSTR
SQLInstall_strdup_multi(LPCSTR str
)
121 for (p
= str
; *p
; p
+= lstrlenA(p
) + 1)
124 len
= MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, NULL
, 0 );
125 ret
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
126 MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, ret
, len
);
132 static LPWSTR
SQLInstall_strdup(LPCSTR str
)
140 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0 );
141 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
142 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
147 /* Convert the wide string or zero-length-terminated list of wide strings to a
148 * narrow string or zero-length-terminated list of narrow strings.
149 * Do not try to emulate windows undocumented excesses (e.g. adding a third \0
152 * mode Indicates the sort of string.
153 * 1 denotes that the buffers contain strings terminated by a single nul
155 * 2 denotes that the buffers contain zero-length-terminated lists
156 * (frequently erroneously referred to as double-null-terminated)
157 * buffer The narrow-character buffer into which to place the result. This
158 * must be a non-null pointer to the first element of a buffer whose
159 * length is passed in buffer_length.
160 * str The wide-character buffer containing the string or list of strings to
161 * be converted. str_length defines how many wide characters in the
162 * buffer are to be converted, including all desired terminating nul
164 * str_length Effective length of str
165 * buffer_length Length of buffer
166 * returned_length A pointer to a variable that will receive the number of
167 * narrow characters placed into the buffer. This pointer
170 static BOOL
SQLInstall_narrow(int mode
, LPSTR buffer
, LPCWSTR str
, WORD str_length
, WORD buffer_length
, WORD
*returned_length
)
172 LPSTR pbuf
; /* allows us to allocate a temporary buffer only if needed */
173 int len
; /* Length of the converted list */
174 BOOL success
= FALSE
;
175 assert(mode
== 1 || mode
== 2);
176 assert(buffer_length
);
177 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, 0, 0, NULL
, NULL
);
180 if (len
> buffer_length
)
182 pbuf
= HeapAlloc(GetProcessHeap(), 0, len
);
188 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, pbuf
, len
, NULL
, NULL
);
193 if (buffer_length
> (mode
- 1))
195 memcpy (buffer
, pbuf
, buffer_length
-mode
);
196 *(buffer
+buffer_length
-mode
) = '\0';
198 *(buffer
+buffer_length
-1) = '\0';
202 *returned_length
= pbuf
== buffer
? len
: buffer_length
;
208 ERR("transferring wide to narrow\n");
212 HeapFree(GetProcessHeap(), 0, pbuf
);
217 ERR("measuring wide to narrow\n");
222 BOOL WINAPI
SQLConfigDataSourceW(HWND hwndParent
, WORD fRequest
,
223 LPCWSTR lpszDriver
, LPCWSTR lpszAttributes
)
228 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_w(lpszDriver
),
229 debugstr_w(lpszAttributes
));
231 for (p
= lpszAttributes
; *p
; p
+= lstrlenW(p
) + 1)
232 FIXME("%s\n", debugstr_w(p
));
237 BOOL WINAPI
SQLConfigDataSource(HWND hwndParent
, WORD fRequest
,
238 LPCSTR lpszDriver
, LPCSTR lpszAttributes
)
240 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_a(lpszDriver
),
241 debugstr_a(lpszAttributes
));
246 static HMODULE
load_config_driver(const WCHAR
*driver
)
248 static WCHAR reg_driver
[] = {'d','r','i','v','e','r',0};
251 WCHAR
*filename
= NULL
;
252 DWORD size
= 0, type
;
255 if ((ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
)) == ERROR_SUCCESS
)
259 if ((ret
= RegOpenKeyW(hkey
, driver
, &hkeydriver
)) == ERROR_SUCCESS
)
261 ret
= RegGetValueW(hkeydriver
, NULL
, reg_driver
, RRF_RT_REG_SZ
, &type
, NULL
, &size
);
262 if(ret
== ERROR_MORE_DATA
)
264 filename
= HeapAlloc(GetProcessHeap(), 0, size
);
267 RegCloseKey(hkeydriver
);
269 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
273 ret
= RegGetValueW(hkeydriver
, NULL
, driver
, RRF_RT_REG_SZ
, &type
, filename
, &size
);
276 RegCloseKey(hkeydriver
);
282 if(ret
!= ERROR_SUCCESS
)
284 HeapFree(GetProcessHeap(), 0, filename
);
285 push_error(ODBC_ERROR_INVALID_DSN
, odbc_error_invalid_dsn
);
289 hmod
= LoadLibraryW(filename
);
290 HeapFree(GetProcessHeap(), 0, filename
);
293 push_error(ODBC_ERROR_LOAD_LIB_FAILED
, odbc_error_load_lib_failed
);
298 static BOOL
write_config_value(const WCHAR
*driver
, const WCHAR
*args
)
301 HKEY hkey
, hkeydriver
;
307 if((ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
)) == ERROR_SUCCESS
)
309 if((ret
= RegOpenKeyW(hkey
, driver
, &hkeydriver
)) == ERROR_SUCCESS
)
311 WCHAR
*divider
, *value
;
313 name
= heap_alloc( (strlenW(args
) + 1) * sizeof(WCHAR
));
316 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
319 lstrcpyW(name
, args
);
321 divider
= strchrW(name
,'=');
324 push_error(ODBC_ERROR_INVALID_KEYWORD_VALUE
, odbc_error_invalid_keyword
);
331 TRACE("Write pair: %s = %s\n", debugstr_w(name
), debugstr_w(value
));
332 if(RegSetValueExW(hkeydriver
, name
, 0, REG_SZ
, (BYTE
*)value
,
333 (strlenW(value
)+1) * sizeof(WCHAR
)) != ERROR_SUCCESS
)
334 ERR("Failed to write registry installed key\n");
337 RegCloseKey(hkeydriver
);
343 if(ret
!= ERROR_SUCCESS
)
344 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
346 return ret
== ERROR_SUCCESS
;
349 RegCloseKey(hkeydriver
);
356 BOOL WINAPI
SQLConfigDriverW(HWND hwnd
, WORD request
, LPCWSTR driver
,
357 LPCWSTR args
, LPWSTR msg
, WORD msgmax
, WORD
*msgout
)
359 BOOL (WINAPI
*pConfigDriverW
)(HWND hwnd
, WORD request
, const WCHAR
*driver
, const WCHAR
*args
, const WCHAR
*msg
, WORD msgmax
, WORD
*msgout
);
361 BOOL funcret
= FALSE
;
364 TRACE("(%p %d %s %s %p %d %p)\n", hwnd
, request
, debugstr_w(driver
),
365 debugstr_w(args
), msg
, msgmax
, msgout
);
367 if(request
== ODBC_CONFIG_DRIVER
)
369 return write_config_value(driver
, args
);
372 hmod
= load_config_driver(driver
);
376 pConfigDriverW
= (void*)GetProcAddress(hmod
, "ConfigDriverW");
378 funcret
= pConfigDriverW(hwnd
, request
, driver
, args
, msg
, msgmax
, msgout
);
381 push_error(ODBC_ERROR_REQUEST_FAILED
, odbc_error_request_failed
);
388 BOOL WINAPI
SQLConfigDriver(HWND hwnd
, WORD request
, LPCSTR driver
,
389 LPCSTR args
, LPSTR msg
, WORD msgmax
, WORD
*msgout
)
391 BOOL (WINAPI
*pConfigDriverA
)(HWND hwnd
, WORD request
, const char *driver
, const char *args
, const char *msg
, WORD msgmax
, WORD
*msgout
);
394 BOOL funcret
= FALSE
;
397 TRACE("(%p %d %s %s %p %d %p)\n", hwnd
, request
, debugstr_a(driver
),
398 debugstr_a(args
), msg
, msgmax
, msgout
);
400 driverW
= heap_strdupAtoW(driver
);
403 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
406 if(request
== ODBC_CONFIG_DRIVER
)
409 WCHAR
*argsW
= heap_strdupAtoW(args
);
412 ret
= write_config_value(driverW
, argsW
);
413 HeapFree(GetProcessHeap(), 0, argsW
);
417 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
420 HeapFree(GetProcessHeap(), 0, driverW
);
425 hmod
= load_config_driver(driverW
);
426 HeapFree(GetProcessHeap(), 0, driverW
);
430 pConfigDriverA
= (void*)GetProcAddress(hmod
, "ConfigDriver");
432 funcret
= pConfigDriverA(hwnd
, request
, driver
, args
, msg
, msgmax
, msgout
);
435 push_error(ODBC_ERROR_REQUEST_FAILED
, odbc_error_request_failed
);
442 BOOL WINAPI
SQLCreateDataSourceW(HWND hwnd
, LPCWSTR lpszDS
)
445 FIXME("%p %s\n", hwnd
, debugstr_w(lpszDS
));
446 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
450 BOOL WINAPI
SQLCreateDataSource(HWND hwnd
, LPCSTR lpszDS
)
453 FIXME("%p %s\n", hwnd
, debugstr_a(lpszDS
));
454 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
458 BOOL WINAPI
SQLGetAvailableDriversW(LPCWSTR lpszInfFile
, LPWSTR lpszBuf
,
459 WORD cbBufMax
, WORD
*pcbBufOut
)
462 FIXME("%s %p %d %p\n", debugstr_w(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
463 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
467 BOOL WINAPI
SQLGetAvailableDrivers(LPCSTR lpszInfFile
, LPSTR lpszBuf
,
468 WORD cbBufMax
, WORD
*pcbBufOut
)
471 FIXME("%s %p %d %p\n", debugstr_a(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
472 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
476 BOOL WINAPI
SQLGetConfigMode(UWORD
*pwConfigMode
)
479 TRACE("%p\n", pwConfigMode
);
481 *pwConfigMode
= config_mode
;
485 BOOL WINAPI
SQLGetInstalledDriversW(WCHAR
*buf
, WORD size
, WORD
*sizeout
)
498 TRACE("%p %d %p\n", buf
, size
, sizeout
);
502 push_error(ODBC_ERROR_INVALID_BUFF_LEN
, odbc_error_invalid_buff_len
);
506 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, drivers_key
, 0, KEY_QUERY_VALUE
, &drivers
);
509 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
514 value
= heap_alloc(valuelen
* sizeof(WCHAR
));
521 res
= RegEnumValueW(drivers
, index
, value
, &len
, NULL
, NULL
, NULL
, NULL
);
522 while (res
== ERROR_MORE_DATA
)
524 value
= heap_realloc(value
, ++len
* sizeof(WCHAR
));
525 res
= RegEnumValueW(drivers
, index
, value
, &len
, NULL
, NULL
, NULL
, NULL
);
527 if (res
== ERROR_SUCCESS
)
529 lstrcpynW(buf
+ written
, value
, size
- written
);
530 written
+= min(len
+ 1, size
- written
);
532 else if (res
== ERROR_NO_MORE_ITEMS
)
536 push_error(ODBC_ERROR_GENERAL_ERR
, odbc_error_general_err
);
546 RegCloseKey(drivers
);
552 BOOL WINAPI
SQLGetInstalledDrivers(char *buf
, WORD size
, WORD
*sizeout
)
558 TRACE("%p %d %p\n", buf
, size
, sizeout
);
562 push_error(ODBC_ERROR_INVALID_BUFF_LEN
, odbc_error_invalid_buff_len
);
566 wbuf
= heap_alloc(size
* sizeof(WCHAR
));
569 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
573 ret
= SQLGetInstalledDriversW(wbuf
, size
, &written
);
577 *sizeout
= WideCharToMultiByte(CP_ACP
, 0, wbuf
, written
, NULL
, 0, NULL
, NULL
);
578 WideCharToMultiByte(CP_ACP
, 0, wbuf
, written
, buf
, size
, NULL
, NULL
);
584 static HKEY
get_privateprofile_sectionkey(LPCWSTR section
, LPCWSTR filename
)
586 HKEY hkey
, hkeyfilename
, hkeysection
;
589 if (RegOpenKeyW(HKEY_CURRENT_USER
, odbcW
, &hkey
))
592 ret
= RegOpenKeyW(hkey
, filename
, &hkeyfilename
);
597 ret
= RegOpenKeyW(hkeyfilename
, section
, &hkeysection
);
598 RegCloseKey(hkeyfilename
);
600 return ret
? NULL
: hkeysection
;
603 int WINAPI
SQLGetPrivateProfileStringW(LPCWSTR section
, LPCWSTR entry
,
604 LPCWSTR defvalue
, LPWSTR buff
, int buff_len
, LPCWSTR filename
)
606 BOOL usedefault
= TRUE
;
610 TRACE("%s %s %s %p %d %s\n", debugstr_w(section
), debugstr_w(entry
),
611 debugstr_w(defvalue
), buff
, buff_len
, debugstr_w(filename
));
615 if (buff_len
<= 0 || !section
)
621 if (!defvalue
|| !buff
)
624 sectionkey
= get_privateprofile_sectionkey(section
, filename
);
631 size
= buff_len
* sizeof(*buff
);
632 if (RegGetValueW(sectionkey
, NULL
, entry
, RRF_RT_REG_SZ
, &type
, buff
, &size
) == ERROR_SUCCESS
)
635 ret
= (size
/ sizeof(*buff
)) - 1;
640 WCHAR name
[MAX_PATH
];
646 memset(buff
, 0, buff_len
);
648 namelen
= sizeof(name
);
649 while (RegEnumValueW(sectionkey
, index
, name
, &namelen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
651 if ((ret
+ namelen
+1) > buff_len
)
654 lstrcpyW(buff
+ret
, name
);
656 namelen
= sizeof(name
);
661 RegCloseKey(sectionkey
);
664 usedefault
= entry
!= NULL
;
668 lstrcpynW(buff
, defvalue
, buff_len
);
669 ret
= lstrlenW(buff
);
675 int WINAPI
SQLGetPrivateProfileString(LPCSTR section
, LPCSTR entry
,
676 LPCSTR defvalue
, LPSTR buff
, int buff_len
, LPCSTR filename
)
678 WCHAR
*sectionW
, *filenameW
;
679 BOOL usedefault
= TRUE
;
683 TRACE("%s %s %s %p %d %s\n", debugstr_a(section
), debugstr_a(entry
),
684 debugstr_a(defvalue
), buff
, buff_len
, debugstr_a(filename
));
694 if (!section
|| !defvalue
|| !buff
)
697 sectionW
= heap_strdupAtoW(section
);
698 filenameW
= heap_strdupAtoW(filename
);
700 sectionkey
= get_privateprofile_sectionkey(sectionW
, filenameW
);
703 heap_free(filenameW
);
711 size
= buff_len
* sizeof(*buff
);
712 if (RegGetValueA(sectionkey
, NULL
, entry
, RRF_RT_REG_SZ
, &type
, buff
, &size
) == ERROR_SUCCESS
)
715 ret
= (size
/ sizeof(*buff
)) - 1;
720 char name
[MAX_PATH
] = {0};
726 memset(buff
, 0, buff_len
);
728 namelen
= sizeof(name
);
729 while (RegEnumValueA(sectionkey
, index
, name
, &namelen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
731 if ((ret
+ namelen
+1) > buff_len
)
734 lstrcpyA(buff
+ret
, name
);
737 namelen
= sizeof(name
);
742 RegCloseKey(sectionkey
);
745 usedefault
= entry
!= NULL
;
749 lstrcpynA(buff
, defvalue
, buff_len
);
756 BOOL WINAPI
SQLGetTranslatorW(HWND hwndParent
, LPWSTR lpszName
, WORD cbNameMax
,
757 WORD
*pcbNameOut
, LPWSTR lpszPath
, WORD cbPathMax
,
758 WORD
*pcbPathOut
, DWORD
*pvOption
)
761 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_w(lpszName
), cbNameMax
,
762 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
763 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
767 BOOL WINAPI
SQLGetTranslator(HWND hwndParent
, LPSTR lpszName
, WORD cbNameMax
,
768 WORD
*pcbNameOut
, LPSTR lpszPath
, WORD cbPathMax
,
769 WORD
*pcbPathOut
, DWORD
*pvOption
)
772 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_a(lpszName
), cbNameMax
,
773 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
774 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
778 BOOL WINAPI
SQLInstallDriverW(LPCWSTR lpszInfFile
, LPCWSTR lpszDriver
,
779 LPWSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
784 TRACE("%s %s %p %d %p\n", debugstr_w(lpszInfFile
),
785 debugstr_w(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
790 return SQLInstallDriverExW(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
791 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
794 BOOL WINAPI
SQLInstallDriver(LPCSTR lpszInfFile
, LPCSTR lpszDriver
,
795 LPSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
800 TRACE("%s %s %p %d %p\n", debugstr_a(lpszInfFile
),
801 debugstr_a(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
806 return SQLInstallDriverEx(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
807 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
810 static void write_registry_values(const WCHAR
*regkey
, const WCHAR
*driver
, const WCHAR
*path_in
, WCHAR
*path
,
813 static const WCHAR installed
[] = {'I','n','s','t','a','l','l','e','d',0};
814 static const WCHAR slash
[] = {'\\', 0};
815 static const WCHAR driverW
[] = {'D','r','i','v','e','r',0};
816 static const WCHAR setupW
[] = {'S','e','t','u','p',0};
817 static const WCHAR translator
[] = {'T','r','a','n','s','l','a','t','o','r',0};
818 HKEY hkey
, hkeydriver
;
820 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
) == ERROR_SUCCESS
)
822 if (RegCreateKeyW(hkey
, regkey
, &hkeydriver
) == ERROR_SUCCESS
)
824 if(RegSetValueExW(hkeydriver
, driver
, 0, REG_SZ
, (BYTE
*)installed
, sizeof(installed
)) != ERROR_SUCCESS
)
825 ERR("Failed to write registry installed key\n");
827 RegCloseKey(hkeydriver
);
830 if (RegCreateKeyW(hkey
, driver
, &hkeydriver
) == ERROR_SUCCESS
)
834 DWORD usagecount
= 0;
837 /* Skip name entry */
839 p
+= lstrlenW(p
) + 1;
842 GetSystemDirectoryW(path
, MAX_PATH
);
844 lstrcpyW(path
, path_in
);
847 size
= sizeof(usagecount
);
848 RegGetValueA(hkeydriver
, NULL
, "UsageCount", RRF_RT_DWORD
, &type
, &usagecount
, &size
);
849 TRACE("Usage count %d\n", usagecount
);
851 for (; *p
; p
+= lstrlenW(p
) + 1)
853 WCHAR
*divider
= strchrW(p
,'=');
860 /* Write pair values to the registry. */
861 lstrcpynW(entry
, p
, divider
- p
+ 1);
864 TRACE("Writing pair %s,%s\n", debugstr_w(entry
), debugstr_w(divider
));
866 /* Driver, Setup, Translator entries use the system path unless a path is specified. */
867 if(lstrcmpiW(driverW
, entry
) == 0 || lstrcmpiW(setupW
, entry
) == 0 ||
868 lstrcmpiW(translator
, entry
) == 0)
870 len
= lstrlenW(path
) + lstrlenW(slash
) + lstrlenW(divider
) + 1;
871 value
= heap_alloc(len
* sizeof(WCHAR
));
874 ERR("Out of memory\n");
878 lstrcpyW(value
, path
);
879 lstrcatW(value
, slash
);
880 lstrcatW(value
, divider
);
884 len
= lstrlenW(divider
) + 1;
885 value
= heap_alloc(len
* sizeof(WCHAR
));
886 lstrcpyW(value
, divider
);
889 if (RegSetValueExW(hkeydriver
, entry
, 0, REG_SZ
, (BYTE
*)value
,
890 (lstrlenW(value
)+1)*sizeof(WCHAR
)) != ERROR_SUCCESS
)
891 ERR("Failed to write registry data %s %s\n", debugstr_w(entry
), debugstr_w(value
));
896 ERR("No pair found. %s\n", debugstr_w(p
));
901 /* Set Usage Count */
903 if (RegSetValueExA(hkeydriver
, "UsageCount", 0, REG_DWORD
, (BYTE
*)&usagecount
, sizeof(usagecount
)) != ERROR_SUCCESS
)
904 ERR("Failed to write registry UsageCount key\n");
907 *usage_count
= usagecount
;
909 RegCloseKey(hkeydriver
);
916 BOOL WINAPI
SQLInstallDriverExW(LPCWSTR lpszDriver
, LPCWSTR lpszPathIn
,
917 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
918 WORD fRequest
, LPDWORD lpdwUsageCount
)
921 WCHAR path
[MAX_PATH
];
924 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver
),
925 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
926 fRequest
, lpdwUsageCount
);
928 write_registry_values(odbcdrivers
, lpszDriver
, lpszPathIn
, path
, lpdwUsageCount
);
930 len
= lstrlenW(path
);
935 if (lpszPathOut
&& cbPathOutMax
> len
)
937 lstrcpyW(lpszPathOut
, path
);
943 BOOL WINAPI
SQLInstallDriverEx(LPCSTR lpszDriver
, LPCSTR lpszPathIn
,
944 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
945 WORD fRequest
, LPDWORD lpdwUsageCount
)
947 LPWSTR driver
, pathin
;
948 WCHAR pathout
[MAX_PATH
];
953 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszDriver
),
954 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
955 fRequest
, lpdwUsageCount
);
957 driver
= SQLInstall_strdup_multi(lpszDriver
);
958 pathin
= SQLInstall_strdup(lpszPathIn
);
960 ret
= SQLInstallDriverExW(driver
, pathin
, pathout
, MAX_PATH
, &cbOut
,
961 fRequest
, lpdwUsageCount
);
964 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
969 *pcbPathOut
= len
- 1;
971 if (!lpszPathOut
|| cbPathOutMax
< len
)
976 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
977 cbPathOutMax
, NULL
, NULL
);
982 HeapFree(GetProcessHeap(), 0, driver
);
983 HeapFree(GetProcessHeap(), 0, pathin
);
987 BOOL WINAPI
SQLInstallDriverManagerW(LPWSTR lpszPath
, WORD cbPathMax
,
991 WCHAR path
[MAX_PATH
];
993 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
995 if (cbPathMax
< MAX_PATH
)
1000 len
= GetSystemDirectoryW(path
, MAX_PATH
);
1005 if (lpszPath
&& cbPathMax
> len
)
1007 lstrcpyW(lpszPath
, path
);
1013 BOOL WINAPI
SQLInstallDriverManager(LPSTR lpszPath
, WORD cbPathMax
,
1017 WORD len
, cbOut
= 0;
1018 WCHAR path
[MAX_PATH
];
1020 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
1022 if (cbPathMax
< MAX_PATH
)
1027 ret
= SQLInstallDriverManagerW(path
, MAX_PATH
, &cbOut
);
1030 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
, 0,
1035 *pcbPathOut
= len
- 1;
1037 if (!lpszPath
|| cbPathMax
< len
)
1040 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
,
1041 cbPathMax
, NULL
, NULL
);
1047 BOOL WINAPI
SQLInstallODBCW(HWND hwndParent
, LPCWSTR lpszInfFile
,
1048 LPCWSTR lpszSrcPath
, LPCWSTR lpszDrivers
)
1051 FIXME("%p %s %s %s\n", hwndParent
, debugstr_w(lpszInfFile
),
1052 debugstr_w(lpszSrcPath
), debugstr_w(lpszDrivers
));
1053 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1057 BOOL WINAPI
SQLInstallODBC(HWND hwndParent
, LPCSTR lpszInfFile
,
1058 LPCSTR lpszSrcPath
, LPCSTR lpszDrivers
)
1061 FIXME("%p %s %s %s\n", hwndParent
, debugstr_a(lpszInfFile
),
1062 debugstr_a(lpszSrcPath
), debugstr_a(lpszDrivers
));
1063 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1067 SQLRETURN WINAPI
SQLInstallerErrorW(WORD iError
, DWORD
*pfErrorCode
,
1068 LPWSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
1070 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
1071 cbErrorMsgMax
, pcbErrorMsg
);
1077 else if (iError
<= num_errors
)
1079 BOOL truncated
= FALSE
;
1084 *pfErrorCode
= error_code
[iError
];
1085 msg
= error_msg
[iError
];
1086 len
= msg
? lstrlenW(msg
) : 0;
1090 if (cbErrorMsgMax
< len
)
1092 len
= cbErrorMsgMax
;
1095 if (lpszErrorMsg
&& len
)
1099 memcpy (lpszErrorMsg
, msg
, len
* sizeof(WCHAR
));
1109 /* Yes. If you pass a null pointer and a large length it is not an error! */
1113 return truncated
? SQL_SUCCESS_WITH_INFO
: SQL_SUCCESS
;
1116 /* At least on Windows 2000 , the buffers are not altered in this case. However that is a little too dangerous a test for just now */
1120 if (lpszErrorMsg
&& cbErrorMsgMax
> 0)
1121 *lpszErrorMsg
= '\0';
1126 SQLRETURN WINAPI
SQLInstallerError(WORD iError
, DWORD
*pfErrorCode
,
1127 LPSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
1132 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
1133 cbErrorMsgMax
, pcbErrorMsg
);
1136 if (lpszErrorMsg
&& cbErrorMsgMax
)
1138 wbuf
= HeapAlloc(GetProcessHeap(), 0, cbErrorMsgMax
*sizeof(WCHAR
));
1142 ret
= SQLInstallerErrorW(iError
, pfErrorCode
, wbuf
, cbErrorMsgMax
, &cbwbuf
);
1146 SQLInstall_narrow(1, lpszErrorMsg
, wbuf
, cbwbuf
+1, cbErrorMsgMax
, &cbBuf
);
1147 HeapFree(GetProcessHeap(), 0, wbuf
);
1149 *pcbErrorMsg
= cbBuf
-1;
1154 BOOL WINAPI
SQLInstallTranslatorExW(LPCWSTR lpszTranslator
, LPCWSTR lpszPathIn
,
1155 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
1156 WORD fRequest
, LPDWORD lpdwUsageCount
)
1159 WCHAR path
[MAX_PATH
];
1162 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszTranslator
),
1163 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
1164 fRequest
, lpdwUsageCount
);
1166 write_registry_values(odbctranslators
, lpszTranslator
, lpszPathIn
, path
, lpdwUsageCount
);
1168 len
= lstrlenW(path
);
1173 if (lpszPathOut
&& cbPathOutMax
> len
)
1175 lstrcpyW(lpszPathOut
, path
);
1181 BOOL WINAPI
SQLInstallTranslatorEx(LPCSTR lpszTranslator
, LPCSTR lpszPathIn
,
1182 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
1183 WORD fRequest
, LPDWORD lpdwUsageCount
)
1186 LPWSTR translator
, pathin
;
1187 WCHAR pathout
[MAX_PATH
];
1192 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszTranslator
),
1193 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
1194 fRequest
, lpdwUsageCount
);
1196 for (p
= lpszTranslator
; *p
; p
+= lstrlenA(p
) + 1)
1197 TRACE("%s\n", debugstr_a(p
));
1199 translator
= SQLInstall_strdup_multi(lpszTranslator
);
1200 pathin
= SQLInstall_strdup(lpszPathIn
);
1202 ret
= SQLInstallTranslatorExW(translator
, pathin
, pathout
, MAX_PATH
,
1203 &cbOut
, fRequest
, lpdwUsageCount
);
1206 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
1211 *pcbPathOut
= len
- 1;
1213 if (!lpszPathOut
|| cbPathOutMax
< len
)
1218 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
1219 cbPathOutMax
, NULL
, NULL
);
1224 HeapFree(GetProcessHeap(), 0, translator
);
1225 HeapFree(GetProcessHeap(), 0, pathin
);
1229 BOOL WINAPI
SQLInstallTranslator(LPCSTR lpszInfFile
, LPCSTR lpszTranslator
,
1230 LPCSTR lpszPathIn
, LPSTR lpszPathOut
, WORD cbPathOutMax
,
1231 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
1234 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_a(lpszInfFile
),
1235 debugstr_a(lpszTranslator
), debugstr_a(lpszPathIn
), lpszPathOut
,
1236 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1241 return SQLInstallTranslatorEx(lpszTranslator
, lpszPathIn
, lpszPathOut
,
1242 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1245 BOOL WINAPI
SQLInstallTranslatorW(LPCWSTR lpszInfFile
, LPCWSTR lpszTranslator
,
1246 LPCWSTR lpszPathIn
, LPWSTR lpszPathOut
, WORD cbPathOutMax
,
1247 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
1250 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_w(lpszInfFile
),
1251 debugstr_w(lpszTranslator
), debugstr_w(lpszPathIn
), lpszPathOut
,
1252 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1257 return SQLInstallTranslatorExW(lpszTranslator
, lpszPathIn
, lpszPathOut
,
1258 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1261 BOOL WINAPI
SQLManageDataSources(HWND hwnd
)
1264 FIXME("%p\n", hwnd
);
1265 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1269 SQLRETURN WINAPI
SQLPostInstallerErrorW(DWORD fErrorCode
, LPCWSTR szErrorMsg
)
1271 FIXME("%u %s\n", fErrorCode
, debugstr_w(szErrorMsg
));
1272 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1276 SQLRETURN WINAPI
SQLPostInstallerError(DWORD fErrorCode
, LPCSTR szErrorMsg
)
1278 FIXME("%u %s\n", fErrorCode
, debugstr_a(szErrorMsg
));
1279 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1283 BOOL WINAPI
SQLReadFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
1284 LPCWSTR lpszKeyName
, LPWSTR lpszString
, WORD cbString
,
1288 FIXME("%s %s %s %s %d %p\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1289 debugstr_w(lpszKeyName
), debugstr_w(lpszString
), cbString
, pcbString
);
1290 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1294 BOOL WINAPI
SQLReadFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1295 LPCSTR lpszKeyName
, LPSTR lpszString
, WORD cbString
,
1299 FIXME("%s %s %s %s %d %p\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1300 debugstr_a(lpszKeyName
), debugstr_a(lpszString
), cbString
, pcbString
);
1301 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1305 BOOL WINAPI
SQLRemoveDefaultDataSource(void)
1309 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1313 BOOL WINAPI
SQLRemoveDriverW(LPCWSTR drivername
, BOOL remove_dsn
, LPDWORD usage_count
)
1316 DWORD usagecount
= 1;
1319 TRACE("%s %d %p\n", debugstr_w(drivername
), remove_dsn
, usage_count
);
1321 if (RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
) == ERROR_SUCCESS
)
1325 if (RegOpenKeyW(hkey
, drivername
, &hkeydriver
) == ERROR_SUCCESS
)
1330 size
= sizeof(usagecount
);
1331 RegGetValueA(hkeydriver
, NULL
, "UsageCount", RRF_RT_DWORD
, &type
, &usagecount
, &size
);
1332 TRACE("Usage count %d\n", usagecount
);
1333 count
= usagecount
- 1;
1336 if (RegSetValueExA(hkeydriver
, "UsageCount", 0, REG_DWORD
, (BYTE
*)&count
, sizeof(count
)) != ERROR_SUCCESS
)
1337 ERR("Failed to write registry UsageCount key\n");
1340 RegCloseKey(hkeydriver
);
1348 if (RegDeleteKeyW(hkey
, drivername
) != ERROR_SUCCESS
)
1349 ERR("Failed to delete registry key: %s\n", debugstr_w(drivername
));
1351 if (RegOpenKeyW(hkey
, odbcdrivers
, &hkeydriver
) == ERROR_SUCCESS
)
1353 if(RegDeleteValueW(hkeydriver
, drivername
) != ERROR_SUCCESS
)
1354 ERR("Failed to delete registry value: %s\n", debugstr_w(drivername
));
1355 RegCloseKey(hkeydriver
);
1363 *usage_count
= usagecount
;
1368 BOOL WINAPI
SQLRemoveDriver(LPCSTR lpszDriver
, BOOL fRemoveDSN
,
1369 LPDWORD lpdwUsageCount
)
1375 TRACE("%s %d %p\n", debugstr_a(lpszDriver
), fRemoveDSN
, lpdwUsageCount
);
1377 driver
= SQLInstall_strdup(lpszDriver
);
1379 ret
= SQLRemoveDriverW(driver
, fRemoveDSN
, lpdwUsageCount
);
1381 HeapFree(GetProcessHeap(), 0, driver
);
1385 BOOL WINAPI
SQLRemoveDriverManager(LPDWORD pdwUsageCount
)
1388 FIXME("%p\n", pdwUsageCount
);
1389 if (pdwUsageCount
) *pdwUsageCount
= 1;
1393 BOOL WINAPI
SQLRemoveDSNFromIniW(LPCWSTR lpszDSN
)
1396 FIXME("%s\n", debugstr_w(lpszDSN
));
1397 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1401 BOOL WINAPI
SQLRemoveDSNFromIni(LPCSTR lpszDSN
)
1404 FIXME("%s\n", debugstr_a(lpszDSN
));
1405 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1409 BOOL WINAPI
SQLRemoveTranslatorW(const WCHAR
*translator
, DWORD
*usage_count
)
1412 DWORD usagecount
= 1;
1416 TRACE("%s %p\n", debugstr_w(translator
), usage_count
);
1418 if (RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
) == ERROR_SUCCESS
)
1422 if (RegOpenKeyW(hkey
, translator
, &hkeydriver
) == ERROR_SUCCESS
)
1427 size
= sizeof(usagecount
);
1428 RegGetValueA(hkeydriver
, NULL
, "UsageCount", RRF_RT_DWORD
, &type
, &usagecount
, &size
);
1429 TRACE("Usage count %d\n", usagecount
);
1430 count
= usagecount
- 1;
1433 if (RegSetValueExA(hkeydriver
, "UsageCount", 0, REG_DWORD
, (BYTE
*)&count
, sizeof(count
)) != ERROR_SUCCESS
)
1434 ERR("Failed to write registry UsageCount key\n");
1437 RegCloseKey(hkeydriver
);
1445 if(RegDeleteKeyW(hkey
, translator
) != ERROR_SUCCESS
)
1447 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
1448 WARN("Failed to delete registry key: %s\n", debugstr_w(translator
));
1452 if (ret
&& RegOpenKeyW(hkey
, odbctranslators
, &hkeydriver
) == ERROR_SUCCESS
)
1454 if(RegDeleteValueW(hkeydriver
, translator
) != ERROR_SUCCESS
)
1456 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
1457 WARN("Failed to delete registry key: %s\n", debugstr_w(translator
));
1461 RegCloseKey(hkeydriver
);
1468 if (ret
&& usage_count
)
1469 *usage_count
= usagecount
;
1474 BOOL WINAPI
SQLRemoveTranslator(LPCSTR lpszTranslator
, LPDWORD lpdwUsageCount
)
1480 TRACE("%s %p\n", debugstr_a(lpszTranslator
), lpdwUsageCount
);
1482 translator
= SQLInstall_strdup(lpszTranslator
);
1483 ret
= SQLRemoveTranslatorW(translator
, lpdwUsageCount
);
1485 HeapFree(GetProcessHeap(), 0, translator
);
1489 BOOL WINAPI
SQLSetConfigMode(UWORD wConfigMode
)
1492 TRACE("%u\n", wConfigMode
);
1494 if (wConfigMode
> ODBC_SYSTEM_DSN
)
1496 push_error(ODBC_ERROR_INVALID_PARAM_SEQUENCE
, odbc_error_invalid_param_sequence
);
1501 config_mode
= wConfigMode
;
1506 BOOL WINAPI
SQLValidDSNW(LPCWSTR lpszDSN
)
1509 FIXME("%s\n", debugstr_w(lpszDSN
));
1510 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1514 BOOL WINAPI
SQLValidDSN(LPCSTR lpszDSN
)
1517 FIXME("%s\n", debugstr_a(lpszDSN
));
1518 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1522 BOOL WINAPI
SQLWriteDSNToIniW(LPCWSTR lpszDSN
, LPCWSTR lpszDriver
)
1525 FIXME("%s %s\n", debugstr_w(lpszDSN
), debugstr_w(lpszDriver
));
1526 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1530 BOOL WINAPI
SQLWriteDSNToIni(LPCSTR lpszDSN
, LPCSTR lpszDriver
)
1533 FIXME("%s %s\n", debugstr_a(lpszDSN
), debugstr_a(lpszDriver
));
1534 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1538 BOOL WINAPI
SQLWriteFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
1539 LPCWSTR lpszKeyName
, LPCWSTR lpszString
)
1542 FIXME("%s %s %s %s\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1543 debugstr_w(lpszKeyName
), debugstr_w(lpszString
));
1544 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1548 BOOL WINAPI
SQLWriteFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1549 LPCSTR lpszKeyName
, LPCSTR lpszString
)
1552 FIXME("%s %s %s %s\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1553 debugstr_a(lpszKeyName
), debugstr_a(lpszString
));
1554 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1558 BOOL WINAPI
SQLWritePrivateProfileStringW(LPCWSTR lpszSection
, LPCWSTR lpszEntry
,
1559 LPCWSTR lpszString
, LPCWSTR lpszFilename
)
1565 TRACE("%s %s %s %s\n", debugstr_w(lpszSection
), debugstr_w(lpszEntry
),
1566 debugstr_w(lpszString
), debugstr_w(lpszFilename
));
1568 if(!lpszFilename
|| !*lpszFilename
)
1570 push_error(ODBC_ERROR_INVALID_STR
, odbc_error_invalid_param_string
);
1574 if ((ret
= RegCreateKeyW(HKEY_CURRENT_USER
, odbcW
, &hkey
)) == ERROR_SUCCESS
)
1578 if ((ret
= RegCreateKeyW(hkey
, lpszFilename
, &hkeyfilename
)) == ERROR_SUCCESS
)
1582 if ((ret
= RegCreateKeyW(hkeyfilename
, lpszSection
, &hkey_section
)) == ERROR_SUCCESS
)
1584 ret
= RegSetValueExW(hkey_section
, lpszEntry
, 0, REG_SZ
, (BYTE
*)lpszString
, (lstrlenW(lpszString
)+1)*sizeof(WCHAR
));
1585 RegCloseKey(hkey_section
);
1588 RegCloseKey(hkeyfilename
);
1594 return ret
== ERROR_SUCCESS
;
1597 BOOL WINAPI
SQLWritePrivateProfileString(LPCSTR lpszSection
, LPCSTR lpszEntry
,
1598 LPCSTR lpszString
, LPCSTR lpszFilename
)
1601 WCHAR
*sect
, *entry
, *string
, *file
;
1603 TRACE("%s %s %s %s\n", lpszSection
, lpszEntry
, lpszString
, lpszFilename
);
1605 sect
= heap_strdupAtoW(lpszSection
);
1606 entry
= heap_strdupAtoW(lpszEntry
);
1607 string
= heap_strdupAtoW(lpszString
);
1608 file
= heap_strdupAtoW(lpszFilename
);
1610 ret
= SQLWritePrivateProfileStringW(sect
, entry
, string
, file
);