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
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
35 #include "wine/heap.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(odbc
);
41 /* Registry key names */
42 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};
43 static const WCHAR odbcW
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C',0};
44 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};
45 static const WCHAR odbcdrivers
[] = {'O','D','B','C',' ','D','r','i','v','e','r','s',0};
46 static const WCHAR odbctranslators
[] = {'O','D','B','C',' ','T','r','a','n','s','l','a','t','o','r','s',0};
48 /* This config mode is known to be process-wide.
49 * MSDN documentation suggests that the value is hidden somewhere in the registry but I haven't found it yet.
50 * Although both the registry and the ODBC.ini files appear to be maintained together they are not maintained automatically through the registry's IniFileMapping.
52 static UWORD config_mode
= ODBC_BOTH_DSN
;
54 /* MSDN documentation suggests that the error subsystem handles errors 1 to 8
55 * only and experimentation (Windows 2000) shows that the errors are process-
56 * wide so go for the simple solution; static arrays.
58 static int num_errors
;
59 static int error_code
[8];
60 static const WCHAR
*error_msg
[8];
61 static const WCHAR odbc_error_general_err
[] = {'G','e','n','e','r','a','l',' ','e','r','r','o','r',0};
62 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};
63 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};
64 static const WCHAR odbc_error_out_of_mem
[] = {'O','u','t',' ','o','f',' ','m','e','m','o','r','y',0};
65 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};
66 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};
67 static const WCHAR odbc_error_invalid_dsn
[] = {'I','n','v','a','l','i','d',' ','D','S','N',0};
68 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};
69 static const WCHAR odbc_error_request_failed
[] = {'R','e','q','u','e','s','t',' ','F','a','i','l','e','d',0};
70 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};
72 /* Push an error onto the error stack, taking care of ranges etc. */
73 static void push_error(int code
, LPCWSTR msg
)
75 if (num_errors
< ARRAY_SIZE(error_code
))
77 error_code
[num_errors
] = code
;
78 error_msg
[num_errors
] = msg
;
83 /* Clear the error stack */
84 static void clear_errors(void)
89 static inline WCHAR
*heap_strdupAtoW(const char *str
)
96 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
97 ret
= heap_alloc(len
*sizeof(WCHAR
));
99 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
106 BOOL WINAPI
ODBCCPlApplet( LONG i
, LONG j
, LONG
* p1
, LONG
* p2
)
109 FIXME( "( %d %d %p %p) : stub!\n", i
, j
, p1
, p2
);
113 static LPWSTR
SQLInstall_strdup_multi(LPCSTR str
)
122 for (p
= str
; *p
; p
+= lstrlenA(p
) + 1)
125 len
= MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, NULL
, 0 );
126 ret
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
127 MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, ret
, len
);
133 static LPWSTR
SQLInstall_strdup(LPCSTR str
)
141 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0 );
142 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
143 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
148 /* Convert the wide string or zero-length-terminated list of wide strings to a
149 * narrow string or zero-length-terminated list of narrow strings.
150 * Do not try to emulate windows undocumented excesses (e.g. adding a third \0
153 * mode Indicates the sort of string.
154 * 1 denotes that the buffers contain strings terminated by a single nul
156 * 2 denotes that the buffers contain zero-length-terminated lists
157 * (frequently erroneously referred to as double-null-terminated)
158 * buffer The narrow-character buffer into which to place the result. This
159 * must be a non-null pointer to the first element of a buffer whose
160 * length is passed in buffer_length.
161 * str The wide-character buffer containing the string or list of strings to
162 * be converted. str_length defines how many wide characters in the
163 * buffer are to be converted, including all desired terminating nul
165 * str_length Effective length of str
166 * buffer_length Length of buffer
167 * returned_length A pointer to a variable that will receive the number of
168 * narrow characters placed into the buffer. This pointer
171 static BOOL
SQLInstall_narrow(int mode
, LPSTR buffer
, LPCWSTR str
, WORD str_length
, WORD buffer_length
, WORD
*returned_length
)
173 LPSTR pbuf
; /* allows us to allocate a temporary buffer only if needed */
174 int len
; /* Length of the converted list */
175 BOOL success
= FALSE
;
176 assert(mode
== 1 || mode
== 2);
177 assert(buffer_length
);
178 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, 0, 0, NULL
, NULL
);
181 if (len
> buffer_length
)
183 pbuf
= HeapAlloc(GetProcessHeap(), 0, len
);
189 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, pbuf
, len
, NULL
, NULL
);
194 if (buffer_length
> (mode
- 1))
196 memcpy (buffer
, pbuf
, buffer_length
-mode
);
197 *(buffer
+buffer_length
-mode
) = '\0';
199 *(buffer
+buffer_length
-1) = '\0';
203 *returned_length
= pbuf
== buffer
? len
: buffer_length
;
209 ERR("transferring wide to narrow\n");
213 HeapFree(GetProcessHeap(), 0, pbuf
);
218 ERR("measuring wide to narrow\n");
223 BOOL WINAPI
SQLConfigDataSourceW(HWND hwndParent
, WORD fRequest
,
224 LPCWSTR lpszDriver
, LPCWSTR lpszAttributes
)
229 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_w(lpszDriver
),
230 debugstr_w(lpszAttributes
));
232 for (p
= lpszAttributes
; *p
; p
+= lstrlenW(p
) + 1)
233 FIXME("%s\n", debugstr_w(p
));
238 BOOL WINAPI
SQLConfigDataSource(HWND hwndParent
, WORD fRequest
,
239 LPCSTR lpszDriver
, LPCSTR lpszAttributes
)
241 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_a(lpszDriver
),
242 debugstr_a(lpszAttributes
));
247 static HMODULE
load_config_driver(const WCHAR
*driver
)
249 static WCHAR reg_driver
[] = {'d','r','i','v','e','r',0};
252 WCHAR
*filename
= NULL
;
253 DWORD size
= 0, type
;
256 if ((ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
)) == ERROR_SUCCESS
)
260 if ((ret
= RegOpenKeyW(hkey
, driver
, &hkeydriver
)) == ERROR_SUCCESS
)
262 ret
= RegGetValueW(hkeydriver
, NULL
, reg_driver
, RRF_RT_REG_SZ
, &type
, NULL
, &size
);
263 if(ret
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
265 RegCloseKey(hkeydriver
);
267 push_error(ODBC_ERROR_INVALID_DSN
, odbc_error_invalid_dsn
);
272 filename
= HeapAlloc(GetProcessHeap(), 0, size
);
275 RegCloseKey(hkeydriver
);
277 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
281 ret
= RegGetValueW(hkeydriver
, NULL
, reg_driver
, RRF_RT_REG_SZ
, &type
, filename
, &size
);
283 RegCloseKey(hkeydriver
);
289 if(ret
!= ERROR_SUCCESS
)
291 HeapFree(GetProcessHeap(), 0, filename
);
292 push_error(ODBC_ERROR_INVALID_DSN
, odbc_error_invalid_dsn
);
296 hmod
= LoadLibraryW(filename
);
297 HeapFree(GetProcessHeap(), 0, filename
);
300 push_error(ODBC_ERROR_LOAD_LIB_FAILED
, odbc_error_load_lib_failed
);
305 static BOOL
write_config_value(const WCHAR
*driver
, const WCHAR
*args
)
308 HKEY hkey
, hkeydriver
;
314 if((ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
)) == ERROR_SUCCESS
)
316 if((ret
= RegOpenKeyW(hkey
, driver
, &hkeydriver
)) == ERROR_SUCCESS
)
318 WCHAR
*divider
, *value
;
320 name
= heap_alloc( (strlenW(args
) + 1) * sizeof(WCHAR
));
323 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
326 lstrcpyW(name
, args
);
328 divider
= strchrW(name
,'=');
331 push_error(ODBC_ERROR_INVALID_KEYWORD_VALUE
, odbc_error_invalid_keyword
);
338 TRACE("Write pair: %s = %s\n", debugstr_w(name
), debugstr_w(value
));
339 if(RegSetValueExW(hkeydriver
, name
, 0, REG_SZ
, (BYTE
*)value
,
340 (strlenW(value
)+1) * sizeof(WCHAR
)) != ERROR_SUCCESS
)
341 ERR("Failed to write registry installed key\n");
344 RegCloseKey(hkeydriver
);
350 if(ret
!= ERROR_SUCCESS
)
351 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
353 return ret
== ERROR_SUCCESS
;
356 RegCloseKey(hkeydriver
);
363 BOOL WINAPI
SQLConfigDriverW(HWND hwnd
, WORD request
, LPCWSTR driver
,
364 LPCWSTR args
, LPWSTR msg
, WORD msgmax
, WORD
*msgout
)
366 BOOL (WINAPI
*pConfigDriverW
)(HWND hwnd
, WORD request
, const WCHAR
*driver
, const WCHAR
*args
, const WCHAR
*msg
, WORD msgmax
, WORD
*msgout
);
368 BOOL funcret
= FALSE
;
371 TRACE("(%p %d %s %s %p %d %p)\n", hwnd
, request
, debugstr_w(driver
),
372 debugstr_w(args
), msg
, msgmax
, msgout
);
374 if(request
== ODBC_CONFIG_DRIVER
)
376 return write_config_value(driver
, args
);
379 hmod
= load_config_driver(driver
);
383 pConfigDriverW
= (void*)GetProcAddress(hmod
, "ConfigDriverW");
385 funcret
= pConfigDriverW(hwnd
, request
, driver
, args
, msg
, msgmax
, msgout
);
388 push_error(ODBC_ERROR_REQUEST_FAILED
, odbc_error_request_failed
);
395 BOOL WINAPI
SQLConfigDriver(HWND hwnd
, WORD request
, LPCSTR driver
,
396 LPCSTR args
, LPSTR msg
, WORD msgmax
, WORD
*msgout
)
398 BOOL (WINAPI
*pConfigDriverA
)(HWND hwnd
, WORD request
, const char *driver
, const char *args
, const char *msg
, WORD msgmax
, WORD
*msgout
);
401 BOOL funcret
= FALSE
;
404 TRACE("(%p %d %s %s %p %d %p)\n", hwnd
, request
, debugstr_a(driver
),
405 debugstr_a(args
), msg
, msgmax
, msgout
);
407 driverW
= heap_strdupAtoW(driver
);
410 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
413 if(request
== ODBC_CONFIG_DRIVER
)
416 WCHAR
*argsW
= heap_strdupAtoW(args
);
419 ret
= write_config_value(driverW
, argsW
);
420 HeapFree(GetProcessHeap(), 0, argsW
);
424 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
427 HeapFree(GetProcessHeap(), 0, driverW
);
432 hmod
= load_config_driver(driverW
);
433 HeapFree(GetProcessHeap(), 0, driverW
);
437 pConfigDriverA
= (void*)GetProcAddress(hmod
, "ConfigDriver");
439 funcret
= pConfigDriverA(hwnd
, request
, driver
, args
, msg
, msgmax
, msgout
);
442 push_error(ODBC_ERROR_REQUEST_FAILED
, odbc_error_request_failed
);
449 BOOL WINAPI
SQLCreateDataSourceW(HWND hwnd
, LPCWSTR lpszDS
)
452 FIXME("%p %s\n", hwnd
, debugstr_w(lpszDS
));
453 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
457 BOOL WINAPI
SQLCreateDataSource(HWND hwnd
, LPCSTR lpszDS
)
460 FIXME("%p %s\n", hwnd
, debugstr_a(lpszDS
));
461 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
465 BOOL WINAPI
SQLGetAvailableDriversW(LPCWSTR lpszInfFile
, LPWSTR lpszBuf
,
466 WORD cbBufMax
, WORD
*pcbBufOut
)
469 FIXME("%s %p %d %p\n", debugstr_w(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
470 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
474 BOOL WINAPI
SQLGetAvailableDrivers(LPCSTR lpszInfFile
, LPSTR lpszBuf
,
475 WORD cbBufMax
, WORD
*pcbBufOut
)
478 FIXME("%s %p %d %p\n", debugstr_a(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
479 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
483 BOOL WINAPI
SQLGetConfigMode(UWORD
*pwConfigMode
)
486 TRACE("%p\n", pwConfigMode
);
488 *pwConfigMode
= config_mode
;
492 BOOL WINAPI
SQLGetInstalledDriversW(WCHAR
*buf
, WORD size
, WORD
*sizeout
)
505 TRACE("%p %d %p\n", buf
, size
, sizeout
);
509 push_error(ODBC_ERROR_INVALID_BUFF_LEN
, odbc_error_invalid_buff_len
);
513 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, drivers_key
, 0, KEY_QUERY_VALUE
, &drivers
);
516 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
521 value
= heap_alloc(valuelen
* sizeof(WCHAR
));
528 res
= RegEnumValueW(drivers
, index
, value
, &len
, NULL
, NULL
, NULL
, NULL
);
529 while (res
== ERROR_MORE_DATA
)
531 value
= heap_realloc(value
, ++len
* sizeof(WCHAR
));
532 res
= RegEnumValueW(drivers
, index
, value
, &len
, NULL
, NULL
, NULL
, NULL
);
534 if (res
== ERROR_SUCCESS
)
536 lstrcpynW(buf
+ written
, value
, size
- written
);
537 written
+= min(len
+ 1, size
- written
);
539 else if (res
== ERROR_NO_MORE_ITEMS
)
543 push_error(ODBC_ERROR_GENERAL_ERR
, odbc_error_general_err
);
553 RegCloseKey(drivers
);
559 BOOL WINAPI
SQLGetInstalledDrivers(char *buf
, WORD size
, WORD
*sizeout
)
565 TRACE("%p %d %p\n", buf
, size
, sizeout
);
569 push_error(ODBC_ERROR_INVALID_BUFF_LEN
, odbc_error_invalid_buff_len
);
573 wbuf
= heap_alloc(size
* sizeof(WCHAR
));
576 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
580 ret
= SQLGetInstalledDriversW(wbuf
, size
, &written
);
587 *sizeout
= WideCharToMultiByte(CP_ACP
, 0, wbuf
, written
, NULL
, 0, NULL
, NULL
);
588 WideCharToMultiByte(CP_ACP
, 0, wbuf
, written
, buf
, size
, NULL
, NULL
);
594 static HKEY
get_privateprofile_sectionkey(LPCWSTR section
, LPCWSTR filename
)
596 HKEY hkey
, hkeyfilename
, hkeysection
;
599 if (RegOpenKeyW(HKEY_CURRENT_USER
, odbcW
, &hkey
))
602 ret
= RegOpenKeyW(hkey
, filename
, &hkeyfilename
);
607 ret
= RegOpenKeyW(hkeyfilename
, section
, &hkeysection
);
608 RegCloseKey(hkeyfilename
);
610 return ret
? NULL
: hkeysection
;
613 int WINAPI
SQLGetPrivateProfileStringW(LPCWSTR section
, LPCWSTR entry
,
614 LPCWSTR defvalue
, LPWSTR buff
, int buff_len
, LPCWSTR filename
)
616 BOOL usedefault
= TRUE
;
620 TRACE("%s %s %s %p %d %s\n", debugstr_w(section
), debugstr_w(entry
),
621 debugstr_w(defvalue
), buff
, buff_len
, debugstr_w(filename
));
625 if (buff_len
<= 0 || !section
)
631 if (!defvalue
|| !buff
)
634 sectionkey
= get_privateprofile_sectionkey(section
, filename
);
641 size
= buff_len
* sizeof(*buff
);
642 if (RegGetValueW(sectionkey
, NULL
, entry
, RRF_RT_REG_SZ
, &type
, buff
, &size
) == ERROR_SUCCESS
)
645 ret
= (size
/ sizeof(*buff
)) - 1;
650 WCHAR name
[MAX_PATH
];
656 memset(buff
, 0, buff_len
);
658 namelen
= sizeof(name
);
659 while (RegEnumValueW(sectionkey
, index
, name
, &namelen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
661 if ((ret
+ namelen
+1) > buff_len
)
664 lstrcpyW(buff
+ret
, name
);
666 namelen
= sizeof(name
);
671 RegCloseKey(sectionkey
);
674 usedefault
= entry
!= NULL
;
678 lstrcpynW(buff
, defvalue
, buff_len
);
679 ret
= lstrlenW(buff
);
685 int WINAPI
SQLGetPrivateProfileString(LPCSTR section
, LPCSTR entry
,
686 LPCSTR defvalue
, LPSTR buff
, int buff_len
, LPCSTR filename
)
688 WCHAR
*sectionW
, *filenameW
;
689 BOOL usedefault
= TRUE
;
693 TRACE("%s %s %s %p %d %s\n", debugstr_a(section
), debugstr_a(entry
),
694 debugstr_a(defvalue
), buff
, buff_len
, debugstr_a(filename
));
704 if (!section
|| !defvalue
|| !buff
)
707 sectionW
= heap_strdupAtoW(section
);
708 filenameW
= heap_strdupAtoW(filename
);
710 sectionkey
= get_privateprofile_sectionkey(sectionW
, filenameW
);
713 heap_free(filenameW
);
721 size
= buff_len
* sizeof(*buff
);
722 if (RegGetValueA(sectionkey
, NULL
, entry
, RRF_RT_REG_SZ
, &type
, buff
, &size
) == ERROR_SUCCESS
)
725 ret
= (size
/ sizeof(*buff
)) - 1;
730 char name
[MAX_PATH
] = {0};
736 memset(buff
, 0, buff_len
);
738 namelen
= sizeof(name
);
739 while (RegEnumValueA(sectionkey
, index
, name
, &namelen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
741 if ((ret
+ namelen
+1) > buff_len
)
744 lstrcpyA(buff
+ret
, name
);
747 namelen
= sizeof(name
);
752 RegCloseKey(sectionkey
);
755 usedefault
= entry
!= NULL
;
759 lstrcpynA(buff
, defvalue
, buff_len
);
766 BOOL WINAPI
SQLGetTranslatorW(HWND hwndParent
, LPWSTR lpszName
, WORD cbNameMax
,
767 WORD
*pcbNameOut
, LPWSTR lpszPath
, WORD cbPathMax
,
768 WORD
*pcbPathOut
, DWORD
*pvOption
)
771 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_w(lpszName
), cbNameMax
,
772 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
773 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
777 BOOL WINAPI
SQLGetTranslator(HWND hwndParent
, LPSTR lpszName
, WORD cbNameMax
,
778 WORD
*pcbNameOut
, LPSTR lpszPath
, WORD cbPathMax
,
779 WORD
*pcbPathOut
, DWORD
*pvOption
)
782 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_a(lpszName
), cbNameMax
,
783 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
784 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
788 BOOL WINAPI
SQLInstallDriverW(LPCWSTR lpszInfFile
, LPCWSTR lpszDriver
,
789 LPWSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
794 TRACE("%s %s %p %d %p\n", debugstr_w(lpszInfFile
),
795 debugstr_w(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
800 return SQLInstallDriverExW(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
801 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
804 BOOL WINAPI
SQLInstallDriver(LPCSTR lpszInfFile
, LPCSTR lpszDriver
,
805 LPSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
810 TRACE("%s %s %p %d %p\n", debugstr_a(lpszInfFile
),
811 debugstr_a(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
816 return SQLInstallDriverEx(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
817 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
820 static void write_registry_values(const WCHAR
*regkey
, const WCHAR
*driver
, const WCHAR
*path_in
, WCHAR
*path
,
823 static const WCHAR installed
[] = {'I','n','s','t','a','l','l','e','d',0};
824 static const WCHAR slash
[] = {'\\', 0};
825 static const WCHAR driverW
[] = {'D','r','i','v','e','r',0};
826 static const WCHAR setupW
[] = {'S','e','t','u','p',0};
827 static const WCHAR translator
[] = {'T','r','a','n','s','l','a','t','o','r',0};
828 HKEY hkey
, hkeydriver
;
830 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
) == ERROR_SUCCESS
)
832 if (RegCreateKeyW(hkey
, regkey
, &hkeydriver
) == ERROR_SUCCESS
)
834 if(RegSetValueExW(hkeydriver
, driver
, 0, REG_SZ
, (BYTE
*)installed
, sizeof(installed
)) != ERROR_SUCCESS
)
835 ERR("Failed to write registry installed key\n");
837 RegCloseKey(hkeydriver
);
840 if (RegCreateKeyW(hkey
, driver
, &hkeydriver
) == ERROR_SUCCESS
)
844 DWORD usagecount
= 0;
847 /* Skip name entry */
849 p
+= lstrlenW(p
) + 1;
852 GetSystemDirectoryW(path
, MAX_PATH
);
854 lstrcpyW(path
, path_in
);
857 size
= sizeof(usagecount
);
858 RegGetValueA(hkeydriver
, NULL
, "UsageCount", RRF_RT_DWORD
, &type
, &usagecount
, &size
);
859 TRACE("Usage count %d\n", usagecount
);
861 for (; *p
; p
+= lstrlenW(p
) + 1)
863 WCHAR
*divider
= strchrW(p
,'=');
870 /* Write pair values to the registry. */
871 lstrcpynW(entry
, p
, divider
- p
+ 1);
874 TRACE("Writing pair %s,%s\n", debugstr_w(entry
), debugstr_w(divider
));
876 /* Driver, Setup, Translator entries use the system path unless a path is specified. */
877 if(lstrcmpiW(driverW
, entry
) == 0 || lstrcmpiW(setupW
, entry
) == 0 ||
878 lstrcmpiW(translator
, entry
) == 0)
880 len
= lstrlenW(path
) + lstrlenW(slash
) + lstrlenW(divider
) + 1;
881 value
= heap_alloc(len
* sizeof(WCHAR
));
884 ERR("Out of memory\n");
888 lstrcpyW(value
, path
);
889 lstrcatW(value
, slash
);
890 lstrcatW(value
, divider
);
894 len
= lstrlenW(divider
) + 1;
895 value
= heap_alloc(len
* sizeof(WCHAR
));
896 lstrcpyW(value
, divider
);
899 if (RegSetValueExW(hkeydriver
, entry
, 0, REG_SZ
, (BYTE
*)value
,
900 (lstrlenW(value
)+1)*sizeof(WCHAR
)) != ERROR_SUCCESS
)
901 ERR("Failed to write registry data %s %s\n", debugstr_w(entry
), debugstr_w(value
));
906 ERR("No pair found. %s\n", debugstr_w(p
));
911 /* Set Usage Count */
913 if (RegSetValueExA(hkeydriver
, "UsageCount", 0, REG_DWORD
, (BYTE
*)&usagecount
, sizeof(usagecount
)) != ERROR_SUCCESS
)
914 ERR("Failed to write registry UsageCount key\n");
917 *usage_count
= usagecount
;
919 RegCloseKey(hkeydriver
);
926 BOOL WINAPI
SQLInstallDriverExW(LPCWSTR lpszDriver
, LPCWSTR lpszPathIn
,
927 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
928 WORD fRequest
, LPDWORD lpdwUsageCount
)
931 WCHAR path
[MAX_PATH
];
934 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver
),
935 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
936 fRequest
, lpdwUsageCount
);
938 write_registry_values(odbcdrivers
, lpszDriver
, lpszPathIn
, path
, lpdwUsageCount
);
940 len
= lstrlenW(path
);
945 if (lpszPathOut
&& cbPathOutMax
> len
)
947 lstrcpyW(lpszPathOut
, path
);
953 BOOL WINAPI
SQLInstallDriverEx(LPCSTR lpszDriver
, LPCSTR lpszPathIn
,
954 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
955 WORD fRequest
, LPDWORD lpdwUsageCount
)
957 LPWSTR driver
, pathin
;
958 WCHAR pathout
[MAX_PATH
];
963 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszDriver
),
964 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
965 fRequest
, lpdwUsageCount
);
967 driver
= SQLInstall_strdup_multi(lpszDriver
);
968 pathin
= SQLInstall_strdup(lpszPathIn
);
970 ret
= SQLInstallDriverExW(driver
, pathin
, pathout
, MAX_PATH
, &cbOut
,
971 fRequest
, lpdwUsageCount
);
974 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
979 *pcbPathOut
= len
- 1;
981 if (!lpszPathOut
|| cbPathOutMax
< len
)
986 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
987 cbPathOutMax
, NULL
, NULL
);
992 HeapFree(GetProcessHeap(), 0, driver
);
993 HeapFree(GetProcessHeap(), 0, pathin
);
997 BOOL WINAPI
SQLInstallDriverManagerW(LPWSTR lpszPath
, WORD cbPathMax
,
1001 WCHAR path
[MAX_PATH
];
1003 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
1005 if (cbPathMax
< MAX_PATH
)
1010 len
= GetSystemDirectoryW(path
, MAX_PATH
);
1015 if (lpszPath
&& cbPathMax
> len
)
1017 lstrcpyW(lpszPath
, path
);
1023 BOOL WINAPI
SQLInstallDriverManager(LPSTR lpszPath
, WORD cbPathMax
,
1027 WORD len
, cbOut
= 0;
1028 WCHAR path
[MAX_PATH
];
1030 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
1032 if (cbPathMax
< MAX_PATH
)
1037 ret
= SQLInstallDriverManagerW(path
, MAX_PATH
, &cbOut
);
1040 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
, 0,
1045 *pcbPathOut
= len
- 1;
1047 if (!lpszPath
|| cbPathMax
< len
)
1050 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
,
1051 cbPathMax
, NULL
, NULL
);
1057 BOOL WINAPI
SQLInstallODBCW(HWND hwndParent
, LPCWSTR lpszInfFile
,
1058 LPCWSTR lpszSrcPath
, LPCWSTR lpszDrivers
)
1061 FIXME("%p %s %s %s\n", hwndParent
, debugstr_w(lpszInfFile
),
1062 debugstr_w(lpszSrcPath
), debugstr_w(lpszDrivers
));
1063 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1067 BOOL WINAPI
SQLInstallODBC(HWND hwndParent
, LPCSTR lpszInfFile
,
1068 LPCSTR lpszSrcPath
, LPCSTR lpszDrivers
)
1071 FIXME("%p %s %s %s\n", hwndParent
, debugstr_a(lpszInfFile
),
1072 debugstr_a(lpszSrcPath
), debugstr_a(lpszDrivers
));
1073 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1077 SQLRETURN WINAPI
SQLInstallerErrorW(WORD iError
, DWORD
*pfErrorCode
,
1078 LPWSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
1080 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
1081 cbErrorMsgMax
, pcbErrorMsg
);
1087 else if (iError
<= num_errors
)
1089 BOOL truncated
= FALSE
;
1094 *pfErrorCode
= error_code
[iError
];
1095 msg
= error_msg
[iError
];
1096 len
= msg
? lstrlenW(msg
) : 0;
1100 if (cbErrorMsgMax
< len
)
1102 len
= cbErrorMsgMax
;
1105 if (lpszErrorMsg
&& len
)
1109 memcpy (lpszErrorMsg
, msg
, len
* sizeof(WCHAR
));
1119 /* Yes. If you pass a null pointer and a large length it is not an error! */
1123 return truncated
? SQL_SUCCESS_WITH_INFO
: SQL_SUCCESS
;
1126 /* 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 */
1130 if (lpszErrorMsg
&& cbErrorMsgMax
> 0)
1131 *lpszErrorMsg
= '\0';
1136 SQLRETURN WINAPI
SQLInstallerError(WORD iError
, DWORD
*pfErrorCode
,
1137 LPSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
1142 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
1143 cbErrorMsgMax
, pcbErrorMsg
);
1146 if (lpszErrorMsg
&& cbErrorMsgMax
)
1148 wbuf
= HeapAlloc(GetProcessHeap(), 0, cbErrorMsgMax
*sizeof(WCHAR
));
1152 ret
= SQLInstallerErrorW(iError
, pfErrorCode
, wbuf
, cbErrorMsgMax
, &cbwbuf
);
1156 SQLInstall_narrow(1, lpszErrorMsg
, wbuf
, cbwbuf
+1, cbErrorMsgMax
, &cbBuf
);
1157 HeapFree(GetProcessHeap(), 0, wbuf
);
1159 *pcbErrorMsg
= cbBuf
-1;
1164 BOOL WINAPI
SQLInstallTranslatorExW(LPCWSTR lpszTranslator
, LPCWSTR lpszPathIn
,
1165 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
1166 WORD fRequest
, LPDWORD lpdwUsageCount
)
1169 WCHAR path
[MAX_PATH
];
1172 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszTranslator
),
1173 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
1174 fRequest
, lpdwUsageCount
);
1176 write_registry_values(odbctranslators
, lpszTranslator
, lpszPathIn
, path
, lpdwUsageCount
);
1178 len
= lstrlenW(path
);
1183 if (lpszPathOut
&& cbPathOutMax
> len
)
1185 lstrcpyW(lpszPathOut
, path
);
1191 BOOL WINAPI
SQLInstallTranslatorEx(LPCSTR lpszTranslator
, LPCSTR lpszPathIn
,
1192 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
1193 WORD fRequest
, LPDWORD lpdwUsageCount
)
1196 LPWSTR translator
, pathin
;
1197 WCHAR pathout
[MAX_PATH
];
1202 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszTranslator
),
1203 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
1204 fRequest
, lpdwUsageCount
);
1206 for (p
= lpszTranslator
; *p
; p
+= lstrlenA(p
) + 1)
1207 TRACE("%s\n", debugstr_a(p
));
1209 translator
= SQLInstall_strdup_multi(lpszTranslator
);
1210 pathin
= SQLInstall_strdup(lpszPathIn
);
1212 ret
= SQLInstallTranslatorExW(translator
, pathin
, pathout
, MAX_PATH
,
1213 &cbOut
, fRequest
, lpdwUsageCount
);
1216 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
1221 *pcbPathOut
= len
- 1;
1223 if (!lpszPathOut
|| cbPathOutMax
< len
)
1228 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
1229 cbPathOutMax
, NULL
, NULL
);
1234 HeapFree(GetProcessHeap(), 0, translator
);
1235 HeapFree(GetProcessHeap(), 0, pathin
);
1239 BOOL WINAPI
SQLInstallTranslator(LPCSTR lpszInfFile
, LPCSTR lpszTranslator
,
1240 LPCSTR lpszPathIn
, LPSTR lpszPathOut
, WORD cbPathOutMax
,
1241 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
1244 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_a(lpszInfFile
),
1245 debugstr_a(lpszTranslator
), debugstr_a(lpszPathIn
), lpszPathOut
,
1246 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1251 return SQLInstallTranslatorEx(lpszTranslator
, lpszPathIn
, lpszPathOut
,
1252 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1255 BOOL WINAPI
SQLInstallTranslatorW(LPCWSTR lpszInfFile
, LPCWSTR lpszTranslator
,
1256 LPCWSTR lpszPathIn
, LPWSTR lpszPathOut
, WORD cbPathOutMax
,
1257 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
1260 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_w(lpszInfFile
),
1261 debugstr_w(lpszTranslator
), debugstr_w(lpszPathIn
), lpszPathOut
,
1262 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1267 return SQLInstallTranslatorExW(lpszTranslator
, lpszPathIn
, lpszPathOut
,
1268 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
1271 BOOL WINAPI
SQLManageDataSources(HWND hwnd
)
1274 FIXME("%p\n", hwnd
);
1275 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1279 SQLRETURN WINAPI
SQLPostInstallerErrorW(DWORD fErrorCode
, LPCWSTR szErrorMsg
)
1281 FIXME("%u %s\n", fErrorCode
, debugstr_w(szErrorMsg
));
1282 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1286 SQLRETURN WINAPI
SQLPostInstallerError(DWORD fErrorCode
, LPCSTR szErrorMsg
)
1288 FIXME("%u %s\n", fErrorCode
, debugstr_a(szErrorMsg
));
1289 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1293 BOOL WINAPI
SQLReadFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
1294 LPCWSTR lpszKeyName
, LPWSTR lpszString
, WORD cbString
,
1298 FIXME("%s %s %s %s %d %p\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1299 debugstr_w(lpszKeyName
), debugstr_w(lpszString
), cbString
, pcbString
);
1300 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1304 BOOL WINAPI
SQLReadFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1305 LPCSTR lpszKeyName
, LPSTR lpszString
, WORD cbString
,
1309 FIXME("%s %s %s %s %d %p\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1310 debugstr_a(lpszKeyName
), debugstr_a(lpszString
), cbString
, pcbString
);
1311 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1315 BOOL WINAPI
SQLRemoveDefaultDataSource(void)
1319 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1323 BOOL WINAPI
SQLRemoveDriverW(LPCWSTR drivername
, BOOL remove_dsn
, LPDWORD usage_count
)
1326 DWORD usagecount
= 1;
1329 TRACE("%s %d %p\n", debugstr_w(drivername
), remove_dsn
, usage_count
);
1331 if (RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
) == ERROR_SUCCESS
)
1335 if (RegOpenKeyW(hkey
, drivername
, &hkeydriver
) == ERROR_SUCCESS
)
1340 size
= sizeof(usagecount
);
1341 RegGetValueA(hkeydriver
, NULL
, "UsageCount", RRF_RT_DWORD
, &type
, &usagecount
, &size
);
1342 TRACE("Usage count %d\n", usagecount
);
1343 count
= usagecount
- 1;
1346 if (RegSetValueExA(hkeydriver
, "UsageCount", 0, REG_DWORD
, (BYTE
*)&count
, sizeof(count
)) != ERROR_SUCCESS
)
1347 ERR("Failed to write registry UsageCount key\n");
1350 RegCloseKey(hkeydriver
);
1358 if (RegDeleteKeyW(hkey
, drivername
) != ERROR_SUCCESS
)
1359 ERR("Failed to delete registry key: %s\n", debugstr_w(drivername
));
1361 if (RegOpenKeyW(hkey
, odbcdrivers
, &hkeydriver
) == ERROR_SUCCESS
)
1363 if(RegDeleteValueW(hkeydriver
, drivername
) != ERROR_SUCCESS
)
1364 ERR("Failed to delete registry value: %s\n", debugstr_w(drivername
));
1365 RegCloseKey(hkeydriver
);
1373 *usage_count
= usagecount
;
1378 BOOL WINAPI
SQLRemoveDriver(LPCSTR lpszDriver
, BOOL fRemoveDSN
,
1379 LPDWORD lpdwUsageCount
)
1385 TRACE("%s %d %p\n", debugstr_a(lpszDriver
), fRemoveDSN
, lpdwUsageCount
);
1387 driver
= SQLInstall_strdup(lpszDriver
);
1389 ret
= SQLRemoveDriverW(driver
, fRemoveDSN
, lpdwUsageCount
);
1391 HeapFree(GetProcessHeap(), 0, driver
);
1395 BOOL WINAPI
SQLRemoveDriverManager(LPDWORD pdwUsageCount
)
1398 FIXME("%p\n", pdwUsageCount
);
1399 if (pdwUsageCount
) *pdwUsageCount
= 1;
1403 BOOL WINAPI
SQLRemoveDSNFromIniW(LPCWSTR lpszDSN
)
1406 FIXME("%s\n", debugstr_w(lpszDSN
));
1407 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1411 BOOL WINAPI
SQLRemoveDSNFromIni(LPCSTR lpszDSN
)
1414 FIXME("%s\n", debugstr_a(lpszDSN
));
1415 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1419 BOOL WINAPI
SQLRemoveTranslatorW(const WCHAR
*translator
, DWORD
*usage_count
)
1422 DWORD usagecount
= 1;
1426 TRACE("%s %p\n", debugstr_w(translator
), usage_count
);
1428 if (RegOpenKeyW(HKEY_LOCAL_MACHINE
, odbcini
, &hkey
) == ERROR_SUCCESS
)
1432 if (RegOpenKeyW(hkey
, translator
, &hkeydriver
) == ERROR_SUCCESS
)
1437 size
= sizeof(usagecount
);
1438 RegGetValueA(hkeydriver
, NULL
, "UsageCount", RRF_RT_DWORD
, &type
, &usagecount
, &size
);
1439 TRACE("Usage count %d\n", usagecount
);
1440 count
= usagecount
- 1;
1443 if (RegSetValueExA(hkeydriver
, "UsageCount", 0, REG_DWORD
, (BYTE
*)&count
, sizeof(count
)) != ERROR_SUCCESS
)
1444 ERR("Failed to write registry UsageCount key\n");
1447 RegCloseKey(hkeydriver
);
1455 if(RegDeleteKeyW(hkey
, translator
) != ERROR_SUCCESS
)
1457 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
1458 WARN("Failed to delete registry key: %s\n", debugstr_w(translator
));
1462 if (ret
&& RegOpenKeyW(hkey
, odbctranslators
, &hkeydriver
) == ERROR_SUCCESS
)
1464 if(RegDeleteValueW(hkeydriver
, translator
) != ERROR_SUCCESS
)
1466 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
1467 WARN("Failed to delete registry key: %s\n", debugstr_w(translator
));
1471 RegCloseKey(hkeydriver
);
1478 if (ret
&& usage_count
)
1479 *usage_count
= usagecount
;
1484 BOOL WINAPI
SQLRemoveTranslator(LPCSTR lpszTranslator
, LPDWORD lpdwUsageCount
)
1490 TRACE("%s %p\n", debugstr_a(lpszTranslator
), lpdwUsageCount
);
1492 translator
= SQLInstall_strdup(lpszTranslator
);
1493 ret
= SQLRemoveTranslatorW(translator
, lpdwUsageCount
);
1495 HeapFree(GetProcessHeap(), 0, translator
);
1499 BOOL WINAPI
SQLSetConfigMode(UWORD wConfigMode
)
1502 TRACE("%u\n", wConfigMode
);
1504 if (wConfigMode
> ODBC_SYSTEM_DSN
)
1506 push_error(ODBC_ERROR_INVALID_PARAM_SEQUENCE
, odbc_error_invalid_param_sequence
);
1511 config_mode
= wConfigMode
;
1516 BOOL WINAPI
SQLValidDSNW(LPCWSTR lpszDSN
)
1518 static const WCHAR invalid
[] = {'[',']','{','}','(',')',',',';','?','*','=','!','@','\\',0};
1520 TRACE("%s\n", debugstr_w(lpszDSN
));
1522 if(strlenW(lpszDSN
) > SQL_MAX_DSN_LENGTH
|| strpbrkW(lpszDSN
, invalid
) != NULL
)
1530 BOOL WINAPI
SQLValidDSN(LPCSTR lpszDSN
)
1532 static const char *invalid
= "[]{}(),;?*=!@\\";
1534 TRACE("%s\n", debugstr_a(lpszDSN
));
1536 if(strlen(lpszDSN
) > SQL_MAX_DSN_LENGTH
|| strpbrk(lpszDSN
, invalid
) != NULL
)
1544 BOOL WINAPI
SQLWriteDSNToIniW(LPCWSTR lpszDSN
, LPCWSTR lpszDriver
)
1547 FIXME("%s %s\n", debugstr_w(lpszDSN
), debugstr_w(lpszDriver
));
1551 BOOL WINAPI
SQLWriteDSNToIni(LPCSTR lpszDSN
, LPCSTR lpszDriver
)
1554 FIXME("%s %s\n", debugstr_a(lpszDSN
), debugstr_a(lpszDriver
));
1558 BOOL WINAPI
SQLWriteFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
1559 LPCWSTR lpszKeyName
, LPCWSTR lpszString
)
1562 FIXME("%s %s %s %s\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1563 debugstr_w(lpszKeyName
), debugstr_w(lpszString
));
1564 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1568 BOOL WINAPI
SQLWriteFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1569 LPCSTR lpszKeyName
, LPCSTR lpszString
)
1572 FIXME("%s %s %s %s\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1573 debugstr_a(lpszKeyName
), debugstr_a(lpszString
));
1574 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1578 BOOL WINAPI
SQLWritePrivateProfileStringW(LPCWSTR lpszSection
, LPCWSTR lpszEntry
,
1579 LPCWSTR lpszString
, LPCWSTR lpszFilename
)
1581 static const WCHAR empty
[] = {0};
1586 TRACE("%s %s %s %s\n", debugstr_w(lpszSection
), debugstr_w(lpszEntry
),
1587 debugstr_w(lpszString
), debugstr_w(lpszFilename
));
1589 if(!lpszFilename
|| !*lpszFilename
)
1591 push_error(ODBC_ERROR_INVALID_STR
, odbc_error_invalid_param_string
);
1595 if ((ret
= RegCreateKeyW(HKEY_CURRENT_USER
, odbcW
, &hkey
)) == ERROR_SUCCESS
)
1599 if ((ret
= RegCreateKeyW(hkey
, lpszFilename
, &hkeyfilename
)) == ERROR_SUCCESS
)
1603 if ((ret
= RegCreateKeyW(hkeyfilename
, lpszSection
, &hkey_section
)) == ERROR_SUCCESS
)
1606 ret
= RegSetValueExW(hkey_section
, lpszEntry
, 0, REG_SZ
, (BYTE
*)lpszString
, (lstrlenW(lpszString
)+1)*sizeof(WCHAR
));
1608 ret
= RegSetValueExW(hkey_section
, lpszEntry
, 0, REG_SZ
, (BYTE
*)empty
, sizeof(empty
));
1609 RegCloseKey(hkey_section
);
1612 RegCloseKey(hkeyfilename
);
1618 return ret
== ERROR_SUCCESS
;
1621 BOOL WINAPI
SQLWritePrivateProfileString(LPCSTR lpszSection
, LPCSTR lpszEntry
,
1622 LPCSTR lpszString
, LPCSTR lpszFilename
)
1625 WCHAR
*sect
, *entry
, *string
, *file
;
1627 TRACE("%s %s %s %s\n", lpszSection
, lpszEntry
, lpszString
, lpszFilename
);
1629 sect
= heap_strdupAtoW(lpszSection
);
1630 entry
= heap_strdupAtoW(lpszEntry
);
1631 string
= heap_strdupAtoW(lpszString
);
1632 file
= heap_strdupAtoW(lpszFilename
);
1634 ret
= SQLWritePrivateProfileStringW(sect
, entry
, string
, file
);