0

I'm wondering on how I could achieve performing a conditional function based on what operating system I'm using, for example,

if ( operatingSystem == Windows7 )
{
   foo()
}
else if ( operatingSystem == WindowsXP )
{
   etc()
}

I am pretty sure predefined macros won't help me with this since you have to choose the OS macro before you compile, I want this program to be flexible and unfortunately preprocessor macros are the only answer I'm getting when I google it. Thank you for your time!

  • already answered here: [http://stackoverflow.com/questions/2877295/get-os-in-c-win32-for-all-versions-of-win][1] [1]: http://stackoverflow.com/questions/2877295/get-os-in-c-win32-for-all-versions-of-win – dweeves Sep 17 '12 at 09:06

1 Answers1

2

You can use GetVersionEx(). Read GetVersionEx function and OSVERSIONINFOEX structure for details on how to interpret the data.

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143