X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FOS%2FDLLManager.cxx;h=727ba18786d834a81acf0e4e941e051ada1204ca;hb=d8ebffc6ece697ddf7b358946ef5d9c9cd7191fe;hp=274c7dc208a76e697bfac59f591a5998477bae4e;hpb=3393941bf8f26babc7b592db434b40c1b747a687;p=cpPlugins.git diff --git a/lib/cpPlugins/OS/DLLManager.cxx b/lib/cpPlugins/OS/DLLManager.cxx index 274c7dc..727ba18 100644 --- a/lib/cpPlugins/OS/DLLManager.cxx +++ b/lib/cpPlugins/OS/DLLManager.cxx @@ -1,25 +1,30 @@ #include -#ifdef cpPlugins_SYS_WINDOWS +#ifdef cpPlugins_OS_Windows # include -#else // cpPlugins_SYS_WINDOWS +#else // cpPlugins_OS_Windows # include -#endif // cpPlugins_SYS_WINDOWS +#endif // cpPlugins_OS_Windows // ------------------------------------------------------------------------- void* cpPlugins::OS::DLLManager:: Load( const std::string& fname, std::string& error ) { void* hnd = NULL; -#ifdef cpPlugins_SYS_WINDOWS +#ifdef cpPlugins_OS_Windows + UINT old = ::SetErrorMode( SEM_FAILCRITICALERRORS ); + ::SetErrorMode( old | SEM_FAILCRITICALERRORS ); hnd = ::LoadLibraryA( fname.c_str( ) ); -#else // cpPlugins_SYS_WINDOWS + ::SetErrorMode( old ); + if( hnd == NULL ) + error = "Could not load library."; +#else // cpPlugins_OS_Windows hnd = dlopen( fname.c_str( ), RTLD_LAZY | RTLD_GLOBAL ); if( hnd == NULL ) error = dlerror( ); else dlerror( ); -#endif // cpPlugins_SYS_WINDOWS +#endif // cpPlugins_OS_Windows return( hnd ); } @@ -27,11 +32,11 @@ Load( const std::string& fname, std::string& error ) void cpPlugins::OS::DLLManager:: UnLoad( void* hnd ) { -#ifdef cpPlugins_SYS_WINDOWS +#ifdef cpPlugins_OS_Windows ::FreeLibrary( ( HMODULE )hnd ); -#else // cpPlugins_SYS_WINDOWS +#else // cpPlugins_OS_Windows dlclose( hnd ); -#endif // cpPlugins_SYS_WINDOWS +#endif // cpPlugins_OS_Windows } // ------------------------------------------------------------------------- @@ -41,11 +46,11 @@ GetFunctionHandle( void* hnd, const std::string& function ) void* f = NULL; if( hnd != NULL ) { -#ifdef cpPlugins_SYS_WINDOWS +#ifdef cpPlugins_OS_Windows f = ::GetProcAddress( ( HMODULE )hnd, function.c_str( ) ); -#else // cpPlugins_SYS_WINDOWS +#else // cpPlugins_OS_Windows f = dlsym( hnd, function.c_str( ) ); -#endif // cpPlugins_SYS_WINDOWS +#endif // cpPlugins_OS_Windows } // fi return( f ); }