OSDN Git Service
(root)
/
mutilities
/
MUtilities.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7f1bad6
)
Fixed is_library_file() for older Windows versions.
author
LoRd_MuldeR
<mulder2@gmx.de>
Sun, 8 May 2016 18:39:23 +0000
(20:39 +0200)
committer
LoRd_MuldeR
<mulder2@gmx.de>
Sun, 8 May 2016 18:39:23 +0000
(20:39 +0200)
src/OSSupport_Win32.cpp
patch
|
blob
|
history
diff --git
a/src/OSSupport_Win32.cpp
b/src/OSSupport_Win32.cpp
index
46bbb4e
..
ce2dd35
100644
(file)
--- a/
src/OSSupport_Win32.cpp
+++ b/
src/OSSupport_Win32.cpp
@@
-1000,27
+1000,46
@@
void MUtils::OS::sleep_ms(const size_t &duration)
// EXECUTABLE CHECK
///////////////////////////////////////////////////////////////////////////////
// EXECUTABLE CHECK
///////////////////////////////////////////////////////////////////////////////
+static bool libraryAsImageResourceSupported()
+{
+ OSVERSIONINFOEXW osvi;
+ memset(&osvi, 0, sizeof(OSVERSIONINFOEXW));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
+ if(GetVersionExW((LPOSVERSIONINFOW)&osvi))
+ {
+ if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ return (osvi.dwMajorVersion >= 6U);
+ }
+ }
+ return false;
+}
+
bool MUtils::OS::is_executable_file(const QString &path)
{
bool MUtils::OS::is_executable_file(const QString &path)
{
- bool bIsExecutable = false;
DWORD binaryType;
if(GetBinaryType(MUTILS_WCHR(QDir::toNativeSeparators(path)), &binaryType))
{
DWORD binaryType;
if(GetBinaryType(MUTILS_WCHR(QDir::toNativeSeparators(path)), &binaryType))
{
-
bIsExecutable = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY
);
+
return ((binaryType == SCS_32BIT_BINARY) || (binaryType == SCS_64BIT_BINARY)
);
}
}
- return bIsExecutable;
+
+ const DWORD errorCode = GetLastError();
+ qWarning("GetBinaryType() failed with error: 0x%08X", errorCode);
+ return false;
}
bool MUtils::OS::is_library_file(const QString &path)
{
}
bool MUtils::OS::is_library_file(const QString &path)
{
- bool bIsLibrary = false;
- const HMODULE hMod = LoadLibraryEx(MUTILS_WCHR(QDir::toNativeSeparators(path)), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
- if (hMod)
+ const DWORD flags = libraryAsImageResourceSupported() ? (LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE) : (LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES);
+ if (const HMODULE hMod = LoadLibraryEx(MUTILS_WCHR(QDir::toNativeSeparators(path)), NULL, flags))
{
{
- bIsLibrary = true;
FreeLibrary(hMod);
FreeLibrary(hMod);
+ return true;
}
}
- return bIsLibrary;
+
+ const DWORD errorCode = GetLastError();
+ qWarning("LoadLibraryEx() failed with error: 0x%08X", errorCode);
+ return false;
}
///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////