35 class SharedObjectLoader {
37 HMODULE shared_object;
39 void ExcludeCurrentDirectory() {
46 if (GetDllDirectory(0, NULL) <= 1) {
47 SetDllDirectory(TEXT(
""));
55 using Ptr = std::shared_ptr<SharedObjectLoader>;
57 #ifdef ENABLE_UNICODE_PATH_SUPPORT 63 explicit SharedObjectLoader(LPCWSTR pluginName) {
64 ExcludeCurrentDirectory();
66 shared_object = LoadLibraryW(pluginName);
69 THROW_IE_EXCEPTION <<
"Cannot load library '" << details::wStringtoMBCSstringChar(std::wstring(pluginName)) <<
"': " << GetLastError()
70 <<
" from cwd: " << _getcwd(cwd,
sizeof(cwd));
75 explicit SharedObjectLoader(LPCSTR pluginName) {
76 ExcludeCurrentDirectory();
78 shared_object = LoadLibraryA(pluginName);
82 <<
" from cwd: " << _getcwd(cwd,
sizeof(cwd));
86 ~SharedObjectLoader() {
87 FreeLibrary(shared_object);
96 void* get_symbol(
const char* symbolName)
const {
98 THROW_IE_EXCEPTION <<
"Cannot get '" << symbolName <<
"' content from unknown library!";
100 auto procAddr =
reinterpret_cast<void*
>(GetProcAddress(shared_object, symbolName));
101 if (procAddr ==
nullptr)
102 THROW_IE_EXCEPTION <<
"GetProcAddress cannot locate method '" << symbolName <<
"': " << GetLastError();
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
Definition: cldnn_config.hpp:16
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
This is a header file with functions related to filesystem operations.
A header file for the main Inference Engine exception.