diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 88ba6dc8f62..f861f077f1c 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -264,7 +264,21 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi QString threadName = std::exchange(thr->d_func()->objectName, {}); if (Q_LIKELY(threadName.isEmpty())) threadName = QString::fromUtf8(thr->metaObject()->className()); +#ifndef QT_WIN_SERVER_2016_COMPAT SetThreadDescription(GetCurrentThread(), reinterpret_cast(threadName.utf16())); +#else + HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll"); + if (kernelbase != NULL) { + typedef HRESULT (WINAPI *DESCFUNC)(HANDLE, PCWSTR); + + DESCFUNC setThreadDescription = + (DESCFUNC)GetProcAddress(kernelbase, "SetThreadDescription"); + if (setThreadDescription != NULL) { + setThreadDescription(GetCurrentThread(), + reinterpret_cast(threadName.utf16())); + } + } +#endif emit thr->started(QThread::QPrivateSignal()); QThread::setTerminationEnabled(true); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index f01c594b6cd..89c73da5e5f 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -212,9 +212,23 @@ void QWindowsUiaMainProvider::raiseNotification(QAccessibleAnnouncementEvent *ev ? NotificationProcessing_ImportantAll : NotificationProcessing_All; QBStr activityId{ QString::fromLatin1("") }; +#if !defined(Q_CC_MSVC) || !defined(QT_WIN_SERVER_2016_COMPAT) UiaRaiseNotificationEvent(provider.Get(), NotificationKind_Other, processing, message.bstr(), activityId.bstr()); +#else + HMODULE uiautomationcore = GetModuleHandleW(L"UIAutomationCore.dll"); + if (uiautomationcore != NULL) { + typedef HRESULT (WINAPI *EVENTFUNC)(IRawElementProviderSimple *, NotificationKind, + NotificationProcessing, BSTR, BSTR); + EVENTFUNC uiaRaiseNotificationEvent = + (EVENTFUNC)GetProcAddress(uiautomationcore, "UiaRaiseNotificationEvent"); + if (uiaRaiseNotificationEvent != NULL) { + uiaRaiseNotificationEvent(provider.Get(), NotificationKind_Other, processing, + message.bstr(), activityId.bstr()); + } + } +#endif } } } diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp index 6954a881d09..144ad36f00e 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp @@ -6,7 +6,7 @@ #include "qwindowsuiautomation.h" -#if defined(__MINGW32__) || defined(__MINGW64__) +#ifndef Q_CC_MSVC template struct winapi_func @@ -77,6 +77,6 @@ HRESULT WINAPI UiaRaiseNotificationEvent( return func.invoke(pProvider, notificationKind, notificationProcessing, displayString, activityId); } -#endif // defined(__MINGW32__) || defined(__MINGW64__) +#endif // !Q_CC_MSVC #endif // QT_CONFIG(accessibility)