1 #include <cpPlugins/OS/DLLManager.h>
3 #ifdef cpPlugins_OS_Windows
5 #else // cpPlugins_OS_Windows
7 #endif // cpPlugins_OS_Windows
9 // -------------------------------------------------------------------------
10 void* cpPlugins::OS::DLLManager::
11 Load( const std::string& fname, std::string& error )
14 #ifdef cpPlugins_OS_Windows
15 UINT old = ::SetErrorMode( SEM_FAILCRITICALERRORS );
16 ::SetErrorMode( old | SEM_FAILCRITICALERRORS );
17 hnd = ::LoadLibraryA( fname.c_str( ) );
18 ::SetErrorMode( old );
20 error = "Could not load library.";
21 #else // cpPlugins_OS_Windows
22 hnd = dlopen( fname.c_str( ), RTLD_LAZY | RTLD_GLOBAL );
27 #endif // cpPlugins_OS_Windows
31 // -------------------------------------------------------------------------
32 void cpPlugins::OS::DLLManager::
35 #ifdef cpPlugins_OS_Windows
36 ::FreeLibrary( ( HMODULE )hnd );
37 #else // cpPlugins_OS_Windows
39 #endif // cpPlugins_OS_Windows
42 // -------------------------------------------------------------------------
43 void* cpPlugins::OS::DLLManager::
44 GetFunctionHandle( void* hnd, const std::string& function )
49 #ifdef cpPlugins_OS_Windows
50 f = ::GetProcAddress( ( HMODULE )hnd, function.c_str( ) );
51 #else // cpPlugins_OS_Windows
52 f = dlsym( hnd, function.c_str( ) );
53 #endif // cpPlugins_OS_Windows