diff --git a/osdep/threads-win32.h b/osdep/threads-win32.h index 2617bcb51b..bfd17095ae 100644 --- a/osdep/threads-win32.h +++ b/osdep/threads-win32.h @@ -198,18 +198,22 @@ static inline int mp_thread_detach(mp_thread thread) wchar_t *mp_from_utf8(void *talloc_ctx, const char *s); static inline void mp_thread_set_name(const char *name) { + HRESULT (WINAPI *pSetThreadDescription)(HANDLE, PCWSTR); #if !HAVE_UWP HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); if (!kernel32) return; - HRESULT (WINAPI *pSetThreadDescription)(HANDLE, PCWSTR) = - (void *) GetProcAddress(kernel32, "SetThreadDescription"); + pSetThreadDescription = (void *) GetProcAddress(kernel32, "SetThreadDescription"); if (!pSetThreadDescription) return; +#else + WINBASEAPI HRESULT WINAPI + SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription); + pSetThreadDescription = &SetThreadDescription; +#endif wchar_t *wname = mp_from_utf8(NULL, name); pSetThreadDescription(GetCurrentThread(), wname); talloc_free(wname); -#endif } static inline int64_t mp_thread_cpu_time_ns(mp_thread_id thread)