Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3428

Show
Ignore:
Timestamp:
04/11/08 00:54:55 (8 months ago)
Author:
kris
Message:

fixes #1040 :: SharedLib? should probably use LoadLibraryW instead of LoadLibraryA

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/sys/SharedLib.d

    r3329 r3428  
    2222        extern (Windows) { 
    2323            void* GetProcAddress(HINSTANCE, char*); 
    24             HINSTANCE LoadLibraryA(char*); 
    2524            BOOL FreeLibrary(HMODULE); 
     25 
     26            version (Win32SansUnicode) 
     27                     HINSTANCE LoadLibraryA(char*); 
     28                else { 
     29                   enum {CP_UTF8 = 65001} 
     30                   HINSTANCE LoadLibraryW(wchar*); 
     31                   int MultiByteToWideChar(uint, uint, char*, int, wchar*, int); 
     32                } 
    2633        } 
    2734    } 
     
    242249 
    243250            void load_(LoadMode mode) { 
    244                 handle = LoadLibraryA((this.path_ ~ \0).ptr); 
     251                version (Win32SansUnicode) 
     252                         handle = LoadLibraryA((this.path_ ~ \0).ptr); 
     253                    else { 
     254                         wchar[1024] tmp = void; 
     255                         auto i = MultiByteToWideChar (CP_UTF8, 0, 
     256                                                       path.ptr, path.length, 
     257                                                       tmp.ptr, tmp.length-1); 
     258                         if (i > 0) 
     259                            { 
     260                            tmp[i] = 0; 
     261                            handle = LoadLibraryW (tmp.ptr); 
     262                            } 
     263                    } 
    245264                if (handle is null && SharedLib.throwExceptions) { 
    246265                    throw new SharedLibException("Couldn't load shared library '" ~ this.path_ ~ "' : " ~ SysError.lastMsg); 
     
    345364    } 
    346365} 
     366 
     367 
     368 
     369 
     370debug (SharedLib) 
     371{ 
     372        void main() 
     373        {        
     374                auto lib = new SharedLib("foo"); 
     375        } 
     376}