Skip to content

Commit

Permalink
add:实现GetModulePath接口
Browse files Browse the repository at this point in the history
  • Loading branch information
GengGode committed Feb 9, 2024
1 parent 45b5708 commit e73ee86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/cvAutoTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ extern "C"
bool CVAUTOTRACK_API GetMapIsEmbedded();
bool CVAUTOTRACK_API GetCompileVersion(char* version_buff, int buff_size);
bool CVAUTOTRACK_API GetCompileTime(char* time_buff, int buff_size);
bool CVAUTOTRACK_API GetModulePath(char* path_buff, int buff_size);

/// @brief
/// @param doc_buff
Expand Down
17 changes: 16 additions & 1 deletion source/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "pch.h"

BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/
static HMODULE g_library_module = NULL;

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpReserved*/
)
{
g_library_module = hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Expand All @@ -11,4 +14,16 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lp
case DLL_PROCESS_DETACH: break;
}
return TRUE;
}

bool GetModulePath(char* path_buff, int buff_size)
{
if (g_library_module == NULL)
{
return false;
}
char module_path_char[MAX_PATH] = { 0 };
GetModuleFileNameA(g_library_module, module_path_char, MAX_PATH);
strcpy_s(path_buff, buff_size, module_path_char);
return true;
}

0 comments on commit e73ee86

Please sign in to comment.