CPathCopyCopyModule::CPathCopyCopyModule Constructor.
| 45 | // Constructor. |
| 46 | // |
| 47 | CPathCopyCopyModule::CPathCopyCopyModule() |
| 48 | : ATL::CAtlDllModuleT<CPathCopyCopyModule>() |
| 49 | { |
| 50 | // Get path to this DLL. We need it to locate our resource DLL. |
| 51 | std::wstring path(MAX_PATH + 1, L'\0'); |
| 52 | #pragma warning(suppress: 26490) // Dirty trick is dirty |
| 53 | if (::GetModuleFileNameW(reinterpret_cast<HMODULE>(&__ImageBase), path.data(), gsl::narrow<DWORD>(path.size())) != 0) { |
| 54 | // Get parent folder containing our DLL and the resource DLLs also. |
| 55 | PCC::PluginUtils::ExtractFolderFromPath(path); |
| 56 | |
| 57 | // First try loading the resource DLL specified in the registry. |
| 58 | // If that fails, load the default one. |
| 59 | const auto tryLoadResourceDll = [&](const std::wstring& language) { |
| 60 | const auto dllPath = path + L"\\" + L"PathCopyCopyLocalization_" + language + L".dll"; |
| 61 | m_hResourceDll = ::LoadLibraryExW(dllPath.c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE); |
| 62 | if (m_hResourceDll != nullptr) { |
| 63 | ATL::_AtlBaseModule.AddResourceInstance(m_hResourceDll); |
| 64 | } |
| 65 | }; |
| 66 | tryLoadResourceDll(GetResourceDllLanguage()); |
| 67 | if (m_hResourceDll == nullptr) { |
| 68 | tryLoadResourceDll(L"en"); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // |
| 74 | // CPathCopyCopyModule::~CPathCopyCopyModule |