1 /*========================== begin_copyright_notice ============================
2 
3 Copyright (C) 2017-2021 Intel Corporation
4 
5 SPDX-License-Identifier: MIT
6 
7 ============================= end_copyright_notice ===========================*/
8 
9 #include "cif/os/win/win_library_handle.h"
10 
11 namespace CIF {
12 
OpenLibrary(const std::string & path,bool addOsSpecificExtensionToPath)13 std::unique_ptr<LibraryHandle> OpenLibrary(const std::string &path, bool addOsSpecificExtensionToPath) {
14   HMODULE mod = NULL;
15   if(addOsSpecificExtensionToPath){
16       mod = LoadLibraryExA((path + ".dll").c_str(), NULL, 0);
17   }else{
18       mod = LoadLibraryExA(path.c_str(), NULL, 0);
19   }
20   return OpenLibrary(UniquePtrHMODULE(mod));
21 }
22 
OpenLibrary(const std::wstring & path,bool addOsSpecificExtensionToPath)23 std::unique_ptr<LibraryHandle> OpenLibrary(const std::wstring &path, bool addOsSpecificExtensionToPath) {
24   HMODULE mod = NULL;
25   if(addOsSpecificExtensionToPath){
26       mod = LoadLibraryExW((path + L".dll").c_str(), NULL, 0);
27   }else{
28       mod = LoadLibraryExW(path.c_str(), NULL, 0);
29   }
30   return OpenLibrary(UniquePtrHMODULE(mod));
31 }
32 }
33