Unofficial ReactOS Blog

Friday, December 30, 2005

Finding ReactOS's Version

Someone the other day was asking on the ReactOS forums if it was possible to detect wether their application was running on ReactOS. While they wanted to use this to detect ReactOS for using work arounds and not stopping the application running altogether, it is still a bad idea. If you find a bug filing it on Bugzilla will get the problem fixed as soon as possible.

Never the less I was still rather interested to see if this was possible. Then GvG later replied with some information on how you could find out the needed information. So I decided to knock up a little test application to try it myself.

Heres the source:

#include <stdio.h>
#include <tchar.h>
#include <windows.h>

int main()
{
OSVERSIONINFO VersionInfo;
LPTSTR RosVersion;

VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
ZeroMemory(VersionInfo.szCSDVersion,
sizeof(VersionInfo.szCSDVersion));

if (GetVersionEx(&VersionInfo) != 0)
{
RosVersion = VersionInfo.szCSDVersion +
_tcslen(VersionInfo.szCSDVersion) + 1;

printf("Windows v%i.%i %s\n", VersionInfo.dwMajorVersion,
VersionInfo.dwMinorVersion,
VersionInfo.szCSDVersion);

if (_tcsnicmp(RosVersion, _T("ReactOS"), 7) == 0)
{
printf("%s\n", RosVersion);
}
else
{
printf("Not Running on ReactOS!\n");
}
}

system("PAUSE");
exit(0);
}
This was compiled with Dev-Cpp/mingw, and is release under the GNU GPL Licence

0 Comments:

Post a Comment

<< Home