1 #include <cpPlugins/OS/DLLManager.h>
3 #ifdef cpPlugins_SYS_WINDOWS
5 #else // cpPlugins_SYS_WINDOWS
7 #endif // cpPlugins_SYS_WINDOWS
9 // -------------------------------------------------------------------------
10 void* cpPlugins::OS::DLLManager::
11 Load( const std::string& fname, std::string& error )
14 #ifdef cpPlugins_SYS_WINDOWS
15 hnd = ::LoadLibraryA( fname.c_str( ) );
16 #else // cpPlugins_SYS_WINDOWS
17 hnd = dlopen( fname.c_str( ), RTLD_LAZY | RTLD_GLOBAL );
22 #endif // cpPlugins_SYS_WINDOWS
26 // -------------------------------------------------------------------------
27 void cpPlugins::OS::DLLManager::
30 #ifdef cpPlugins_SYS_WINDOWS
31 ::FreeLibrary( ( HMODULE )hnd );
32 #else // cpPlugins_SYS_WINDOWS
34 #endif // cpPlugins_SYS_WINDOWS
37 // -------------------------------------------------------------------------
38 void* cpPlugins::OS::DLLManager::
39 GetFunctionHandle( void* hnd, const std::string& function )
44 #ifdef cpPlugins_SYS_WINDOWS
45 f = ::GetProcAddress( ( HMODULE )hnd, function.c_str( ) );
46 #else // cpPlugins_SYS_WINDOWS
47 f = dlsym( hnd, function.c_str( ) );
48 #endif // cpPlugins_SYS_WINDOWS