|
23 | 23 | /* NOTE If you change something in this program, please consider if other platform's version |
24 | 24 | of the function you are changing, needs to be changed accordingly */ |
25 | 25 |
|
26 | | -#include <ma_odbc.h> |
27 | | -#include "Shlwapi.h" |
| 26 | +#include "ma_odbc.h" |
| 27 | +#include <pathcch.h> |
28 | 28 |
|
29 | 29 | extern Client_Charset utf8; |
30 | 30 | char LogFile[256]; |
@@ -295,23 +295,25 @@ BOOL MADB_DirectoryExists(const char *Path) |
295 | 295 | return (FileAttributes != INVALID_FILE_ATTRIBUTES) && (FileAttributes & FILE_ATTRIBUTE_DIRECTORY); |
296 | 296 | } |
297 | 297 |
|
298 | | -const char* MADB_GetDefaultPluginsDir(MADB_Dbc *Dbc) |
| 298 | +char* MADB_GetDefaultPluginsDir(char* Buffer, size_t Size) |
299 | 299 | { |
300 | 300 | HMODULE hModule = GetModuleHandle(MADB_DRIVER_NAME); |
301 | | - static char OurLocation[_MAX_PATH]; |
| 301 | + wchar_t wOurLocation[_MAX_PATH]; |
302 | 302 | const char *PluginsSubDirName= "\\"MADB_DEFAULT_PLUGINS_SUBDIR; |
| 303 | + HRESULT hr; |
303 | 304 |
|
304 | | - memset(OurLocation, 0, sizeof(OurLocation)); |
305 | | - GetModuleFileName(hModule, OurLocation, _MAX_PATH); |
306 | | - PathRemoveFileSpec(OurLocation); |
| 305 | + memset(Buffer, 0, Size); |
| 306 | + GetModuleFileNameW(hModule, wOurLocation, _MAX_PATH); |
| 307 | + hr= PathCchRemoveFileSpec(wOurLocation, _MAX_PATH); |
307 | 308 |
|
308 | | - if (strlen(OurLocation) < _MAX_PATH - strlen(PluginsSubDirName)) |
| 309 | + WideCharToMultiByte(GetACP(), 0, wOurLocation, -1, Buffer, Size, NULL, NULL); |
| 310 | + if (strlen(Buffer) < Size - strlen(PluginsSubDirName)) |
309 | 311 | { |
310 | | - strcpy(OurLocation + strlen(OurLocation), PluginsSubDirName); |
| 312 | + strcpy(Buffer + strlen(Buffer), PluginsSubDirName); |
311 | 313 |
|
312 | | - if (MADB_DirectoryExists(OurLocation) != FALSE) |
| 314 | + if (MADB_DirectoryExists(Buffer) != FALSE) |
313 | 315 | { |
314 | | - return OurLocation; |
| 316 | + return Buffer; |
315 | 317 | } |
316 | 318 | } |
317 | 319 | return NULL; |
|
0 commit comments