获取当前dll所在的路径
extern "C" IMAGE_DOS_HEADER __ImageBase;
static HMODULE GetCurrentModule()
{
return reinterpret_cast<HMODULE>(&__ImageBase);
}
static std::string GetDynamicLibraryPath()
{
HMODULE hModule = NULL;
char DLLPATH[MAX_PATH + 1] = { 0 };
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)GetCurrentModule, &hModule);
::GetModuleFileName(hModule, DLLPATH, MAX_PATH);
std::string DllPath = DLLPATH;
return DllPath;
}