开发者

Detecting run-time game platform in XNA

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?


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
 }


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.


The best way is to check the preprocessor flags

#if WINDOWS
// do stuff
#endif

#if XBOX360
// do stuff
#endif

##if ZUNE
// do stuff
##endif
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜