From 88285acae1b02da35aa1dd21170cd876781df186 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 6 Jan 2021 11:28:38 +0000 Subject: [PATCH] DragAndDrop: Fix drag and drop in windows optimised builds In very optimised builds, SHCore.dll may not be automatically loaded into the address space of the calling executable. In these cases, the call to `GetModuleHandle` will fail. Adding the call to LoadLibrary ensures that the dll is loaded into the program's address space, which will allow the call to GetModuleHandle to succeed. --- modules/juce_gui_basics/native/juce_win32_Windowing.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index db874e4818..6e91316b63 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -362,7 +362,9 @@ static void setDPIAwareness() if (! JUCEApplicationBase::isStandaloneApp()) return; - HMODULE shcoreModule = GetModuleHandleA ("SHCore.dll"); + const auto shcore = "SHCore.dll"; + LoadLibraryA (shcore); + const auto shcoreModule = GetModuleHandleA (shcore); if (shcoreModule != nullptr) {