views:

96

answers:

4

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

Is there a way to detect the platform (XBox, Windows, Zune) during run-time?

A: 

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

drudru
this should be a comment to the question, not an answer.
thephpdeveloper
+2  A: 

You can use Environment.OSVersion to obtain information on the Platform and Version. The Platform property will likely tell you what you want, although I don't know for sure if the returned strings will be enough to tell the different platforms apart. I'd be surprised if they didn't though.

Morten Mertner
+3  A: 

Environment.OSVersion is what you want. Per the MSDN doc, you would use it like:

 OperatingSystem os = Environment.OSVersion;
 PlatformID pid = os.Platform;
 switch (pid) 
 {
   //Do whatever
 }
Joe
didn't thought that it can be a non-XNA related solution =D
thephpdeveloper
+1  A: 

The best way is to check the preprocessor flags

#if WINDOWS
// do stuff
#endif

#if XBOX360
// do stuff
#endif

##if ZUNE
// do stuff
##endif
David Amador