~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to third-party/cppunit/cppunit/src/cppunit/Win32DynamicLibraryManager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

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