19 #define TEST_DYNAMIC_LIB 1 // Test for DLL export. 20 #include <coil/DynamicLib.h> 32 : m_closeflag(close_handle_on_destruction)
45 int close_handle_on_destruction)
46 : m_name(dynlib_name), m_mode(open_mode),
47 m_closeflag(close_handle_on_destruction)
49 if (open(m_name.c_str(), m_mode, m_closeflag) != 0)
51 throw std::bad_alloc();
77 if (!rhs.m_name.empty() &&
78 open(rhs.m_name.c_str(), rhs.m_mode, rhs.m_closeflag) == 0)
80 throw std::bad_alloc();
93 std::swap(this->
m_name, tmp.m_name);
94 std::swap(this->
m_mode, tmp.m_mode);
96 std::swap(this->
m_handle, tmp.m_handle);
109 int close_handle_on_destruction)
111 HINSTANCE handle = ::LoadLibraryEx(dll_name, NULL, open_mode);
146 return ::GetProcAddress(
m_handle, symbol_name);
159 static char cstr[256] =
"";
162 dwcode = ::GetLastError();
165 ::SetLastError(ERROR_SUCCESS);
176 FORMAT_MESSAGE_FROM_SYSTEM |
177 FORMAT_MESSAGE_IGNORE_INSERTS,
180 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
static int ForExternTest(void)
Unit Test.
void * symbol(const char *symbol_name)
Return an address of the memory where a symbol was loaded.
DynamicLib & operator=(const DynamicLib &rhs)
Assignment operator.
DynamicLib(int close_handle_on_destruction=1)
Constructor.
virtual ~DynamicLib()
Destructor.
virtual int close(void)
Unload of the Dynamic link library.
const char * error(void) const
Return the explanation message about the error.
virtual int open(const char *dll_name, int open_mode=COIL_DEFAULT_DYNLIB_MODE, int close_handle_on_destruction=1)
Load of the Dynamic link library.
Common Object Interface Layer.