Is there a macro to detect the operating system ...?

I plan to write a code snippet using the media API that is available after Vista. I want to add code inside the #if block something like ...

#if <SomeMacro>
// all the classes using MediaFoundation go here.
#endif

I could not find a macro to determine the version of the operating system. How is this usually done on windows? I found that _WIN32 and _WIN64 detect 32-bit and 64-bit, but not macros to determine api availability. Is there a better way to isolate code based on API accessibility in vc ..?

Thank you, Abhinay.

+3
source share
3 answers

. , , WIN32_WINNT, , - XP.

+2

Try macros _WIN32_WINNTand WINVER. More details here: http://msdn.microsoft.com/en-us/library/aa383745%28VS.85%29.aspx

Try something like

#ifdef _WIN32_WINNT_VISTA
    #if WINVER >= _WIN32_WINNT_VISTA
        //....
    #endif
#endif
+1
source

Source: https://habr.com/ru/post/1776507/


All Articles