Browse Source

Tidied up some win32 DLL loading code, and fixed a call type mismatch with the windows media format class.

tags/2021-05-28
jules 13 years ago
parent
commit
584c444ffd
5 changed files with 17 additions and 17 deletions
  1. +2
    -2
      modules/juce_audio_devices/native/juce_win32_WASAPI.cpp
  2. +2
    -3
      modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp
  3. +4
    -4
      modules/juce_core/native/juce_BasicNativeHeaders.h
  4. +5
    -6
      modules/juce_core/native/juce_win32_Network.cpp
  5. +4
    -2
      modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp

+ 2
- 2
modules/juce_audio_devices/native/juce_win32_WASAPI.cpp View File

@@ -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)
{


+ 2
- 3
modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp View File

@@ -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)
{


+ 4
- 4
modules/juce_core/native/juce_BasicNativeHeaders.h View File

@@ -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


+ 5
- 6
modules/juce_core/native/juce_win32_Network.cpp View File

@@ -370,7 +370,7 @@ namespace MACAddressHelpers
void getViaGetAdaptersInfo (Array<MACAddress>& 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<MACAddress>& 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;


+ 4
- 2
modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp View File

@@ -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)
{


Loading…
Cancel
Save