Skip to content

Commit

Permalink
Fixed some issues for compiling under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
heikohimu committed Oct 21, 2021
1 parent 514965b commit 7ff202d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions rc_genicam_api/gentl_wrapper_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ std::vector<std::string> getAvailableGenTLs(const char *paths)
// get all files with suffix .cti

HANDLE p;
WIN32_FIND_DATA data;
WIN32_FIND_DATAA data;

std::string dir=path;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -219,4 +219,4 @@ GenTLWrapper::~GenTLWrapper()
FreeLibrary(static_cast<HMODULE>(lib));
}

}
}
47 changes: 24 additions & 23 deletions rc_genicam_api/system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int find(const std::vector<std::shared_ptr<System> > &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<LPCSTR>(&getPathToThisDll), &hm) == 0)
Expand All @@ -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 {};
}
Expand Down Expand Up @@ -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';

Expand All @@ -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;
}
Expand All @@ -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

Expand Down Expand Up @@ -249,7 +250,7 @@ std::vector<std::shared_ptr<System> > System::getSystems()
System *p=new System(name[i]);
ret.push_back(std::shared_ptr<System>(p));
}
catch (const std::exception &)
catch (const std::exception &ex)
{
// ignore transport layers that cannot be used
}
Expand Down

0 comments on commit 7ff202d

Please sign in to comment.