win平台下增加DllMain入口函数并添加模块路径全局变量
This commit is contained in:
parent
dbd490b67c
commit
ae50bc7d72
|
@ -922,6 +922,8 @@ int hg_scanner::setting_help(void* data)
|
||||||
printf("helpfile = %s\r\n",helpfile.c_str());
|
printf("helpfile = %s\r\n",helpfile.c_str());
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
com = "";
|
||||||
|
helpfile.insert(0, g_module_path);
|
||||||
FILE* src = fopen(helpfile.c_str(), "rb");
|
FILE* src = fopen(helpfile.c_str(), "rb");
|
||||||
if (src)
|
if (src)
|
||||||
fclose(src);
|
fclose(src);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "PaperSize.h"
|
#include "PaperSize.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
extern std::string g_module_path; // Ending with '\\'
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -373,6 +374,6 @@ public:
|
||||||
#else
|
#else
|
||||||
static const std::string helpfile_ ="/opt/apps/scanner-driver-huagao/doc/HuaGoScan_scanSettings_Help_manual.pdf";//帮助文档路径
|
static const std::string helpfile_ ="/opt/apps/scanner-driver-huagao/doc/HuaGoScan_scanSettings_Help_manual.pdf";//帮助文档路径
|
||||||
#endif
|
#endif
|
||||||
#else
|
#elif defined(WIN32)
|
||||||
static const std::string helpfile_ ="";
|
static const std::string helpfile_ = "docs\\help_setting.pdf";
|
||||||
#endif
|
#endif
|
|
@ -98,4 +98,29 @@ extern "C"
|
||||||
{
|
{
|
||||||
return hg_scanner_mgr::instance()->hg_scanner_control(h, code, data, len);
|
return hg_scanner_mgr::instance()->hg_scanner_control(h, code, data, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
std::string g_module_path = "";
|
||||||
|
|
||||||
|
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
|
||||||
|
{
|
||||||
|
if (reason == DLL_PROCESS_ATTACH)
|
||||||
|
{
|
||||||
|
if (g_module_path.empty())
|
||||||
|
{
|
||||||
|
char path[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
|
GetModuleFileNameA(inst, path, _countof(path) - 1);
|
||||||
|
if (strrchr(path, '\\'))
|
||||||
|
{
|
||||||
|
strrchr(path, '\\')[1] = 0;
|
||||||
|
g_module_path = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -2696,3 +2696,26 @@ extern "C" { // avoid compiler exporting name in C++ style !!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
std::string g_module_path = "";
|
||||||
|
|
||||||
|
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
|
||||||
|
{
|
||||||
|
if (reason == DLL_PROCESS_ATTACH)
|
||||||
|
{
|
||||||
|
if (g_module_path.empty())
|
||||||
|
{
|
||||||
|
char path[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
|
GetModuleFileNameA(inst, path, _countof(path) - 1);
|
||||||
|
if (strrchr(path, '\\'))
|
||||||
|
{
|
||||||
|
strrchr(path, '\\')[1] = 0;
|
||||||
|
g_module_path = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define bzero(b, s) memset(b, 0, s)
|
#define bzero(b, s) memset(b, 0, s)
|
||||||
|
extern std::string g_module_path; // Ending with '\\'
|
||||||
#else
|
#else
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue