Browse Source

Windows: Restored MinGW compatibility

tags/2021-05-28
ed 5 years ago
parent
commit
b7c8ac3f3b
2 changed files with 55 additions and 22 deletions
  1. +4
    -2
      modules/juce_audio_devices/native/juce_win32_Midi.cpp
  2. +51
    -20
      modules/juce_core/native/juce_win32_SystemStats.cpp

+ 4
- 2
modules/juce_audio_devices/native/juce_win32_Midi.cpp View File

@@ -1794,13 +1794,15 @@ private:
//==============================================================================
//==============================================================================
extern RTL_OSVERSIONINFOW getWindowsVersionInfo();
#if ! JUCE_MINGW
extern RTL_OSVERSIONINFOW getWindowsVersionInfo();
#endif
struct MidiService : public DeletedAtShutdown
{
MidiService()
{
#if JUCE_USE_WINRT_MIDI
#if JUCE_USE_WINRT_MIDI && ! JUCE_MINGW
#if ! JUCE_FORCE_WINRT_MIDI
auto windowsVersionInfo = getWindowsVersionInfo();
if (windowsVersionInfo.dwMajorVersion >= 10 && windowsVersionInfo.dwBuildNumber >= 17763)


+ 51
- 20
modules/juce_core/native/juce_win32_SystemStats.cpp View File

@@ -185,32 +185,63 @@ static DebugFlagsInitialiser debugFlagsInitialiser;
#endif
//==============================================================================
RTL_OSVERSIONINFOW getWindowsVersionInfo()
{
RTL_OSVERSIONINFOW versionInfo = { 0 };
if (auto* moduleHandle = ::GetModuleHandleW (L"ntdll.dll"))
{
using RtlGetVersion = LONG (WINAPI*) (PRTL_OSVERSIONINFOW);
if (auto* rtlGetVersion = (RtlGetVersion) ::GetProcAddress (moduleHandle, "RtlGetVersion"))
{
versionInfo.dwOSVersionInfoSize = sizeof (versionInfo);
LONG STATUS_SUCCESS = 0;
if (rtlGetVersion (&versionInfo) != STATUS_SUCCESS)
versionInfo = { 0 };
}
}
return versionInfo;
}
#if JUCE_MINGW
static uint32 getWindowsVersion()
{
auto filename = _T("kernel32.dll");
DWORD handle = 0;
if (auto size = GetFileVersionInfoSize (filename, &handle))
{
HeapBlock<char> data (size);
if (GetFileVersionInfo (filename, handle, size, data))
{
VS_FIXEDFILEINFO* info = nullptr;
UINT verSize = 0;
if (VerQueryValue (data, (LPCTSTR) _T("\\"), (void**) &info, &verSize))
if (size > 0 && info != nullptr && info->dwSignature == 0xfeef04bd)
return (uint32) info->dwFileVersionMS;
}
}
return 0;
}
#else
RTL_OSVERSIONINFOW getWindowsVersionInfo()
{
RTL_OSVERSIONINFOW versionInfo = { 0 };
if (auto* moduleHandle = ::GetModuleHandleW (L"ntdll.dll"))
{
using RtlGetVersion = LONG (WINAPI*) (PRTL_OSVERSIONINFOW);
if (auto* rtlGetVersion = (RtlGetVersion) ::GetProcAddress (moduleHandle, "RtlGetVersion"))
{
versionInfo.dwOSVersionInfoSize = sizeof (versionInfo);
LONG STATUS_SUCCESS = 0;
if (rtlGetVersion (&versionInfo) != STATUS_SUCCESS)
versionInfo = { 0 };
}
}
return versionInfo;
}
#endif
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
{
#if JUCE_MINGW
auto v = getWindowsVersion();
auto major = (v >> 16) & 0xff;
auto minor = (v >> 0) & 0xff;
#else
auto versionInfo = getWindowsVersionInfo();
auto major = versionInfo.dwMajorVersion;
auto minor = versionInfo.dwMinorVersion;
#endif
jassert (major <= 10); // need to add support for new version!


Loading…
Cancel
Save