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?
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?
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.
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
}
The best way is to check the preprocessor flags
#if WINDOWS
// do stuff
#endif
#if XBOX360
// do stuff
#endif
##if ZUNE
// do stuff
##endif