@@ -94,14 +94,57 @@ void archdep_opencbm_fix_dll_path(void)
9494 opencbm_fix_tried = 1 ;
9595}
9696
97+ #ifdef _UNICODE
98+ static const WCHAR * alloc_wchar_from_char (const char * text )
99+ {
100+ int len ;
101+ WCHAR * wtext ;
102+
103+ /* Calculate required length (uses CP_ACP scheme) */
104+ len = MultiByteToWideChar (CP_ACP , 0 , text , -1 , NULL , 0 );
105+
106+ /* Get the space for the converted string */
107+ wtext = (WCHAR * )malloc (len * sizeof (WCHAR ));
108+ if (wtext == NULL )
109+ return NULL ;
110+
111+ /* Convert the string to WCHAR */
112+ MultiByteToWideChar (CP_ACP , 0 , text , -1 , wtext , len );
113+
114+ return wtext ;
115+ }
116+ #endif
117+
97118void * vice_dynlib_open (const char * name )
98119{
99- return LoadLibrary (TEXT (name ));
120+ #ifdef _UNICODE
121+ WCHAR * wname = alloc_wchar_from_char (name );
122+ /* No need to test the value of wname, LoadLibrary()
123+ returns NULL if the parameter is also NULL. */
124+ HMODULE handle = LoadLibrary (wname );
125+ /* Free the allocated file name */
126+ free (wname );
127+
128+ return (void * )handle ;
129+ #else
130+ return LoadLibrary (name );
131+ #endif
100132}
101133
102134void * vice_dynlib_symbol (void * handle ,const char * name )
103135{
136+ /* Windows CE has a sligthly different handling because
137+ the name of the exported function is also unicode */
138+ #ifdef _WIN32_WCE
139+ WCHAR * wname = alloc_wchar_from_char (name );
140+ void * address = GetProcAddress ((HMODULE )handle , wname );
141+ /* Free the allocated file name */
142+ free (wname );
143+
144+ return address ;
145+ #else
104146 return GetProcAddress ((HMODULE )handle , name );
147+ #endif
105148}
106149
107150char * vice_dynlib_error (void )
0 commit comments