Runtime platform determination?

What's the suggested way of determining, at runtime, whether we're on Windows or the 360 Getting the PlatformID & if WinCE then we're on the 360



Answer this question

Runtime platform determination?

  • Jeffrey Welch

    Bit confused by this one. Surely you would need two builds, one for each platform, regardless of which two platforms you are targetting.

    So what would knowing your platform at runtime give you

    If you required different assets on each platform, it would be more wasteful to include both sets of assets and then only load the correct one, than to have a windows build with only windows assets and an xbox build with only xbox assets.

    Advantages to the way XNA does it are :

    Smaller builds.
    Optimisable code.







  • averge joe

    I saw this line in SpacewarGame.cs

    currentPlatform = System.Environment.OSVersion.Platform;

    Spacewar doesn't actually seem to do anything with this value but I wonder if you will get back a different value on xbox than you will on PC



  • Spenceee

    That seems funny. I'm not actually sure what that will give back on Xbox. There isn't a specific define for Xbox in the CLR system platform enum, because that was defined long before the CLR guys even knew Xbox was going have .NET on it!


  • Lakshmi N

    I don't understand why that's a problem

    You already have to compile your code twice for Windows and Xbox. What would be gained by having this available as a runtime API


  • jackwc

    #ifdef XBOX
    // I'm on Xbox
    #else
    // Not on Xbox
    #endif



  • Zapp

    Yeah I don't understand what possible benefit a runtime check would buy you. If you don't want to litter your code with ifdefs you can just wrap a single ifdef/else in a bool method or property and call or reference that as needed. What difference does it make to any of your code if that method/property isn't figuring it out at runtime



  • IXOYE333

    ^_^

    So if you get back null your program thinks it is in limbo!

    That is quite funny!


  • Virtual Reality

    Not exactly runtime, but I guess it'll have to do.


  • Runtime platform determination?