From 7ff202dd13c961afebdebb811a95646af2254b4c Mon Sep 17 00:00:00 2001 From: Heiko Hirschmueller Date: Thu, 21 Oct 2021 21:14:20 +0200 Subject: [PATCH] Fixed some issues for compiling under Windows --- rc_genicam_api/gentl_wrapper_win32.cc | 6 ++-- rc_genicam_api/system.cc | 47 ++++++++++++++------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/rc_genicam_api/gentl_wrapper_win32.cc b/rc_genicam_api/gentl_wrapper_win32.cc index 810444d..12bd3bc 100644 --- a/rc_genicam_api/gentl_wrapper_win32.cc +++ b/rc_genicam_api/gentl_wrapper_win32.cc @@ -72,7 +72,7 @@ std::vector getAvailableGenTLs(const char *paths) // get all files with suffix .cti HANDLE p; - WIN32_FIND_DATA data; + WIN32_FIND_DATAA data; std::string dir=path; @@ -129,7 +129,7 @@ GenTLWrapper::GenTLWrapper(const std::string &filename) { // open library - HMODULE lp=LoadLibrary(filename.c_str()); + HMODULE lp=LoadLibraryA(filename.c_str()); if (lp == 0) { @@ -219,4 +219,4 @@ GenTLWrapper::~GenTLWrapper() FreeLibrary(static_cast(lib)); } -} \ No newline at end of file +} diff --git a/rc_genicam_api/system.cc b/rc_genicam_api/system.cc index 63f0fad..abf6596 100644 --- a/rc_genicam_api/system.cc +++ b/rc_genicam_api/system.cc @@ -87,7 +87,7 @@ int find(const std::vector > &list, const std::string &f static std::string getPathToThisDll() { HMODULE hm = nullptr; - if (GetModuleHandleEx( + if (GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(&getPathToThisDll), &hm) == 0) @@ -96,7 +96,7 @@ static std::string getPathToThisDll() } char path[MAX_PATH]; - if (GetModuleFileName(hm, path, sizeof(path)) == 0) + if (GetModuleFileNameA(hm, path, sizeof(path)) == 0) { return {}; } @@ -129,7 +129,7 @@ bool System::setSystemsPath(const char *path, const char *ignore) const size_t n=256; char procpath[n]; std::string path_to_exe; - if (GetModuleFileName(NULL, procpath, n-1) > 0) + if (GetModuleFileNameA(NULL, procpath, n-1) > 0) { procpath[n-1]='\0'; @@ -138,7 +138,7 @@ bool System::setSystemsPath(const char *path, const char *ignore) path_to_exe=procpath; - if (system_path.size() > 0) system_path+=";"; + if (system_path.size() > 0) system_path+=";"; system_path += path_to_exe; } @@ -148,30 +148,31 @@ bool System::setSystemsPath(const char *path, const char *ignore) const auto path_to_this_dll = getPathToThisDll(); if (!path_to_this_dll.empty() && path_to_this_dll != path_to_exe) { - if (system_path.size() > 0) system_path+=";"; + if (system_path.size() > 0) system_path+=";"; system_path += path_to_this_dll; } // and possible sub-directories of the library - HANDLE file_handle; - WIN32_FIND_DATA file_info; - - file_handle=FindFirstFileA((path_to_this_dll+"\\*").c_str(), &file_info); - if (file_handle != INVALID_HANDLE_VALUE) - { - do - { - if ((file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && file_info.cFileName[0] != '.' ) - { - system_path += ";" + path_to_this_dll + "\\" + file_info.cFileName; - } - } - while (FindNextFileA(file_handle, &file_info)); - - FindClose(file_handle); - } + HANDLE file_handle; + WIN32_FIND_DATAA file_info; + + file_handle=FindFirstFileA((path_to_this_dll+"\\*").c_str(), &file_info); + + if (file_handle != INVALID_HANDLE_VALUE) + { + do + { + if ((file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && file_info.cFileName[0] != '.' ) + { + system_path += ";" + path_to_this_dll + "\\" + file_info.cFileName; + } + } + while (FindNextFileA(file_handle, &file_info)); + + FindClose(file_handle); + } #else // otherwise, use the absolute install path to the default transport layer @@ -249,7 +250,7 @@ std::vector > System::getSystems() System *p=new System(name[i]); ret.push_back(std::shared_ptr(p)); } - catch (const std::exception &) + catch (const std::exception &ex) { // ignore transport layers that cannot be used }