From 7f1bad6ca15d3cae798915b1b8021b37021c151a Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 8 May 2016 19:24:09 +0200 Subject: [PATCH] Added is_library_file() function. --- include/MUtils/OSSupport.h | 3 ++- src/OSSupport_Win32.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/MUtils/OSSupport.h b/include/MUtils/OSSupport.h index 4d425ff..d470d03 100644 --- a/include/MUtils/OSSupport.h +++ b/include/MUtils/OSSupport.h @@ -140,8 +140,9 @@ namespace MUtils //Sleep MUTILS_API void sleep_ms(const size_t &duration); - //Is executable file? + //Is executable/library file? MUTILS_API bool is_executable_file(const QString &path); + MUTILS_API bool is_library_file(const QString &path); //Shutdown & Hibernation MUTILS_API bool is_hibernation_supported(void); diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index 604b9cc..46bbb4e 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -1011,6 +1011,18 @@ bool MUtils::OS::is_executable_file(const QString &path) return bIsExecutable; } +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) + { + bIsLibrary = true; + FreeLibrary(hMod); + } + return bIsLibrary; +} + /////////////////////////////////////////////////////////////////////////////// // HIBERNATION / SHUTDOWN ///////////////////////////////////////////////////////////////////////////////