diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 951f304420..c7c2072b0c 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -829,8 +829,8 @@ public: void setMMThreadPriority() { DynamicLibrary dll ("avrt.dll"); - JUCE_DLL_FUNCTION (AvSetMmThreadCharacteristicsW, avSetMmThreadCharacteristics, HANDLE, dll, (LPCWSTR, LPDWORD)) - JUCE_DLL_FUNCTION (AvSetMmThreadPriority, avSetMmThreadPriority, HANDLE, dll, (HANDLE, AVRT_PRIORITY)) + JUCE_LOAD_WINAPI_FUNCTION (dll, AvSetMmThreadCharacteristicsW, avSetMmThreadCharacteristics, HANDLE, (LPCWSTR, LPDWORD)) + JUCE_LOAD_WINAPI_FUNCTION (dll, AvSetMmThreadPriority, avSetMmThreadPriority, HANDLE, (HANDLE, AVRT_PRIORITY)) if (avSetMmThreadCharacteristics != 0 && avSetMmThreadPriority != 0) { diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 0733b8c735..a48d6d8057 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -134,9 +134,8 @@ public: currentPosition (0), bufferStart (0), bufferEnd (0) { - typedef HRESULT (*WMCreateSyncReaderType) (IUnknown*, DWORD, IWMSyncReader**); - WMCreateSyncReaderType wmCreateSyncReader = nullptr; - wmCreateSyncReader = (WMCreateSyncReaderType) wmvCoreLib.getFunction ("WMCreateSyncReader"); + JUCE_LOAD_WINAPI_FUNCTION (wmvCoreLib, WMCreateSyncReader, wmCreateSyncReader, + HRESULT, (IUnknown*, DWORD, IWMSyncReader**)) if (wmCreateSyncReader != nullptr) { diff --git a/modules/juce_core/native/juce_BasicNativeHeaders.h b/modules/juce_core/native/juce_BasicNativeHeaders.h index 5eda355f5d..1f23a7d37f 100644 --- a/modules/juce_core/native/juce_BasicNativeHeaders.h +++ b/modules/juce_core/native/juce_BasicNativeHeaders.h @@ -142,17 +142,17 @@ #endif #endif - /* Used with DynamicLibrary to simplify importing functions + /* Used with DynamicLibrary to simplify importing functions from a win32 DLL. + dll: the DynamicLibrary object functionName: function to import localFunctionName: name you want to use to actually call it (must be different) returnType: the return type - object: the DynamicLibrary to use params: list of params (bracketed) */ - #define JUCE_DLL_FUNCTION(functionName, localFunctionName, returnType, object, params) \ + #define JUCE_LOAD_WINAPI_FUNCTION(dll, functionName, localFunctionName, returnType, params) \ typedef returnType (WINAPI *type##localFunctionName) params; \ - type##localFunctionName localFunctionName = (type##localFunctionName)object.getFunction (#functionName); + type##localFunctionName localFunctionName = (type##localFunctionName) dll.getFunction (#functionName); //============================================================================== #elif JUCE_LINUX diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index 8b3e4ad5ea..b59646c66a 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -370,7 +370,7 @@ namespace MACAddressHelpers void getViaGetAdaptersInfo (Array& result) { DynamicLibrary dll ("iphlpapi.dll"); - JUCE_DLL_FUNCTION (GetAdaptersInfo, getAdaptersInfo, DWORD, dll, (PIP_ADAPTER_INFO, PULONG)) + JUCE_LOAD_WINAPI_FUNCTION (dll, GetAdaptersInfo, getAdaptersInfo, DWORD, (PIP_ADAPTER_INFO, PULONG)) if (getAdaptersInfo != nullptr) { @@ -392,7 +392,7 @@ namespace MACAddressHelpers void getViaNetBios (Array& result) { DynamicLibrary dll ("netapi32.dll"); - JUCE_DLL_FUNCTION (Netbios, NetbiosCall, UCHAR, dll, (PNCB)) + JUCE_LOAD_WINAPI_FUNCTION (dll, Netbios, NetbiosCall, UCHAR, (PNCB)) if (NetbiosCall != 0) { @@ -449,10 +449,9 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, const String& bodyText, const StringArray& filesToAttach) { - typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); - - DynamicLibrary mapiLib ("MAPI32.dll"); - MAPISendMailType mapiSendMail = (MAPISendMailType) mapiLib.getFunction ("MAPISendMail"); + DynamicLibrary dll ("MAPI32.dll"); + JUCE_LOAD_WINAPI_FUNCTION (dll, MAPISendMail, mapiSendMail, + ULONG, (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG)) if (mapiSendMail == nullptr) return false; diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp index 4cd18af3a1..9bf8eab6a3 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp @@ -72,7 +72,8 @@ public: { if (direct2dDll.open ("d2d1.dll")) { - JUCE_DLL_FUNCTION (D2D1CreateFactory, d2d1CreateFactory, HRESULT, direct2dDll, (D2D1_FACTORY_TYPE, REFIID, D2D1_FACTORY_OPTIONS*, void**)) + JUCE_LOAD_WINAPI_FUNCTION (direct2dDll, D2D1CreateFactory, d2d1CreateFactory, + HRESULT, (D2D1_FACTORY_TYPE, REFIID, D2D1_FACTORY_OPTIONS*, void**)) if (d2d1CreateFactory != nullptr) { @@ -86,7 +87,8 @@ public: if (directWriteDll.open ("DWrite.dll")) { - JUCE_DLL_FUNCTION (DWriteCreateFactory, dWriteCreateFactory, HRESULT, directWriteDll, (DWRITE_FACTORY_TYPE, REFIID, IUnknown**)) + JUCE_LOAD_WINAPI_FUNCTION (directWriteDll, DWriteCreateFactory, dWriteCreateFactory, + HRESULT, (DWRITE_FACTORY_TYPE, REFIID, IUnknown**)) if (dWriteCreateFactory != nullptr) {