C++ Checking for Windows XP/2000

(1/1)

Richard Marks:
If you are making a windows game that you know you are using some things that Win 95/98 users simply cannot use, then you should add code to tell the user that their computer will not play the game.

Here is something I whipped up to do just that.

First a simple boolean function to do the windows os version check cleanly.

Code:

bool UserIsRunningWindows2KOrHigher()
{
OSVERSIONINFO v = {sizeof(v)}; GetVersionEx(&v);
return (bool)((v.dwPlatformId == VER_PLATFORM_WIN32_NT && v.dwMajorVersion >= 5));
}


Now here is a fictional WinMain using some preprocessor macro magic to hide the details of windows stuff. I had made a framework that worked like this a long time ago, but I've lost it and have never rewritten another one.
Code:

IMPLEMENT_WINMAIN();
START_BLOCK;
if (UserIsRunningWindows2KOrHigher())
{
Game* game = new Game("My Cool Game", RUN_FULLSCREEN);
game->Start(GET_WINDOW_INSTANCE(), GET_APP_ARGS());
delete game;
return 0;
}
else
{
return CriticalError("You must run this game on Windows 2000, XP or higher!");
}
END_BLOCK;


So yeah a single function and some code to explain how to use it.

Have fun.

Navigation

[0] Message Index