diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index ca926c0..ab2c54f 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -922,6 +922,8 @@ int hg_scanner::setting_help(void* data) printf("helpfile = %s\r\n",helpfile.c_str()); #ifdef WIN32 + com = ""; + helpfile.insert(0, g_module_path); FILE* src = fopen(helpfile.c_str(), "rb"); if (src) fclose(src); diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index 73bb09e..d6ee98e 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -22,6 +22,7 @@ #include "PaperSize.h" #ifdef WIN32 +extern std::string g_module_path; // Ending with '\\' #else #include #endif @@ -373,6 +374,6 @@ public: #else static const std::string helpfile_ ="/opt/apps/scanner-driver-huagao/doc/HuaGoScan_scanSettings_Help_manual.pdf";//帮助文档路径 #endif -#else - static const std::string helpfile_ =""; +#elif defined(WIN32) + static const std::string helpfile_ = "docs\\help_setting.pdf"; #endif \ No newline at end of file diff --git a/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp b/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp index c4df4f6..b36b3a0 100644 --- a/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp +++ b/hgdriver/wrapper/huagaoxxx_warraper_ex.cpp @@ -98,4 +98,29 @@ extern "C" { return hg_scanner_mgr::instance()->hg_scanner_control(h, code, data, len); } -} \ No newline at end of file +} + + +#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 diff --git a/hgsane/sane_hg_mdw.cpp b/hgsane/sane_hg_mdw.cpp index aff1691..960d4f8 100644 --- a/hgsane/sane_hg_mdw.cpp +++ b/hgsane/sane_hg_mdw.cpp @@ -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 diff --git a/hgsane/sane_option.h b/hgsane/sane_option.h index aa825ac..8572db9 100644 --- a/hgsane/sane_option.h +++ b/hgsane/sane_option.h @@ -9,6 +9,7 @@ #include #ifdef WIN32 #define bzero(b, s) memset(b, 0, s) +extern std::string g_module_path; // Ending with '\\' #else #include #endif