XNA Runtime Game Platform Detection

I am working on a C # XNA project that requires me to display information on the platform the game is on.

Is there a way to detect the platform (XBox, Windows, Zune) at runtime?

+2


source to share


4 answers


Environment.OSVersion is what you want. In the MSDN doc, you should use it like:



 OperatingSystem os = Environment.OSVersion;
 PlatformID pid = os.Platform;
 switch (pid) 
 {
   //Do whatever
 }

      

+3


source


You can use Environment.OSVersion

to get platform and version information. The Platform property will most likely tell you what you want, although I don't know for sure if the returned strings will be enough to separate different platforms. I would be surprised if they didn't.



+2


source


The best way is to check the preprocessor flags

#if WINDOWS
// do stuff
#endif

#if XBOX360
// do stuff
#endif

##if ZUNE
// do stuff
##endif

      

+2


source


They probably have an API that will give you the OS version.

-2


source







All Articles