Is there a macro to detect the operating system…?
-
27-09-2019 - |
문제
I am planning to write a piece of code using the media foundation API which is available after vista. I want to add the code inside a #if block something like...
#if <SomeMacro>
// all the classes using MediaFoundation go here.
#endif
I could not find a macro to detect the operating system version. How is this normally done on windows?? I found _WIN32 and _WIN64 to detect 32-bit and 64-bit but no macros to determine api availability. Is there a better way of isolating code based on API availability in vc..?
Thanks, Abhinay.
해결책
Yes, here they are: http://msdn.microsoft.com/en-us/library/aa383745(VS.85).aspx
다른 팁
Not really. The best you can do is to key off the WIN32_WINNT macro, but that doesn't help you if someone turns around and tries to run your application on XP.
Try the _WIN32_WINNT
and WINVER
macros. More info 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