QWindowsTheme: Suppress error dialogs when calling SHGetFileInfo().

Set the error mode flag SEM_NOOPENFILEERRORBOX when calling Win32 API
SHGetFileInfo() to prevent it from prompting to insert media
as does QStorageInfoPrivate::mountedVolumes().

Task-number: QTBUG-32457
Task-number: QTBUG-48823
Change-Id: I01a2f99b5a75b39dd729509ca319f634e3dcd695
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
bb10
Friedemann Kleint 2016-05-23 09:41:06 +02:00
parent 17a4384d12
commit c96ddd9ee5
1 changed files with 10 additions and 1 deletions

View File

@ -132,7 +132,16 @@ public:
explicit ShGetFileInfoFunction(const wchar_t *fn, DWORD a, SHFILEINFO *i, UINT f, bool *r) :
m_fileName(fn), m_attributes(a), m_flags(f), m_info(i), m_result(r) {}
void operator()() const { *m_result = SHGetFileInfo(m_fileName, m_attributes, m_info, sizeof(SHFILEINFO), m_flags); }
void operator()() const
{
#ifndef Q_OS_WINCE
const UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif
*m_result = SHGetFileInfo(m_fileName, m_attributes, m_info, sizeof(SHFILEINFO), m_flags);
#ifndef Q_OS_WINCE
SetErrorMode(oldErrorMode);
#endif
}
private:
const wchar_t *m_fileName;