blob: 0a82a88e485e2102f81ae0d1273e86e23a3941f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include <cppunit/Portability.h>
#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
#include <cppunit/plugin/DynamicLibraryManager.h>
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOUSER
#define NOKERNEL
#define NOSOUND
#define NOMINMAX
#include <windows.h>
CPPUNIT_NS_BEGIN
DynamicLibraryManager::LibraryHandle
DynamicLibraryManager::doLoadLibrary( const std::string &libraryName )
{
return ::LoadLibrary( libraryName.c_str() );
}
void
DynamicLibraryManager::doReleaseLibrary()
{
::FreeLibrary( (HINSTANCE)m_libraryHandle );
}
DynamicLibraryManager::Symbol
DynamicLibraryManager::doFindSymbol( const std::string &symbol )
{
return (DynamicLibraryManager::Symbol)::GetProcAddress(
(HINSTANCE)m_libraryHandle,
symbol.c_str() );
}
std::string
DynamicLibraryManager::getLastErrorDetail() const
{
LPVOID lpMsgBuf;
::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
std::string message = (LPCTSTR)lpMsgBuf;
// Display the string.
// ::MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
::LocalFree( lpMsgBuf );
return message;
}
CPPUNIT_NS_END
#endif // defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
|