dynamic_library_win.cpp
Go to the documentation of this file.
1 
11 #include "dynamic_library.h"
12 
14 
15 #include <windows.h>
16 
17 namespace
18 {
19 
20 void * LoadDll(const char * path)
21 {
22  // TODO Use SetDllDirctory to search inside installation path.
23  void * library = LoadLibrary(path);
24 
25  if (!library)
26  {
27  std::string msg;
28  // TODO Get windows error string.
30  }
31 
32  return library;
33 }
34 
35 }
36 
37 namespace Common
38 {
39 
41  : Path(libraryPath)
42  , Library(0)
43 {
44 }
45 
47 {
48  if (Library)
49  {
50  FreeLibrary((HMODULE)Library);
51  }
52 }
53 
54 void * DynamicLibrary::FindSymbol(const std::string & funcName)
55 {
56  if (!Library)
57  {
58  Library = LoadDll(Path.c_str());
59  }
60 
61  void * func = (void *)GetProcAddress((HMODULE)Library, funcName.c_str());
62 
63  if (!func)
64  {
65  std::string msg;
66  // TODO GetWindows error string.
68  }
69 
70  return func;
71 }
72 
73 }
Addon interface definition GNU LGPL.
const std::string Path
void * FindSymbol(const std::string &funcName)
Common::ErrorData UnableToLoadDynamicLibrary
DynamicLibrary(const std::string &libraryPath)
#define THROW_ERROR2(data, param1, param2)
Definition: exception.h:215
Common::ErrorData UnableToFundSymbolInTheLibrary
#define THROW_ERROR3(data, param1, param2, param3)
Definition: exception.h:218


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:04