Search code examples
c++windows-phone-8windows-phonewindows-phone-8.1

Detecting Windows Phone version in C++ or C++/CX


It seems that Windows Media Foundation works slightly different in Windows 8.1.

And we need to add some code that looks like this:

#if WINDOWS_81
    DX::ThrowIfFailed(
        MFStartup(MF_VERSION)
        );
#endif

How can we check to see what version of Windows Phone is running via C++?

Thanks!


Solution

  • You can use WINVER to see / control which version the build is targeting at command time. See Using the Windows Headers.

    // 0x0603 for Windows / Windows Phone 8.1
    #if WINVER >= 0x0603
        DX::ThrowIfFailed(
            MFStartup(MF_VERSION)
            );
    #endif
    

    If the only reason is for the MFStartup check then you can leave out the conditional. It is required for 8.1, but it should work fine for 8.0.