Added winver information for windows me and windows server 2003.
[wine/gsoc_dplay.git] / programs / osversioncheck / osversioncheck.c
blob9092f5c5698dab36f210a44feb5eb9e87fedbd03
1 /*
2 * Use the GetVersionEx() Win32 API call to show information about
3 * which version of Windows we're running (or which version of Windows
4 * Wine believes it is masquerading as).
6 * Copyright 1999 by Morten Eriksen <mailto:mortene@sim.no>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <windows.h>
25 #include <winbase.h>
26 #include <stdio.h>
28 void
29 show_last_error(void)
31 DWORD lasterr;
32 LPTSTR buffer;
33 BOOL result;
35 lasterr = GetLastError();
37 result = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
38 FORMAT_MESSAGE_FROM_SYSTEM |
39 FORMAT_MESSAGE_IGNORE_INSERTS,
40 NULL,
41 lasterr,
43 (LPTSTR)&buffer,
45 NULL);
47 if (result) {
48 fprintf(stderr, "Win32 API error (%ld):\t%s", lasterr, buffer);
49 LocalFree((HLOCAL)buffer);
51 else {
52 fprintf(stderr, "Win32 API error (%ld)", lasterr);
56 int
57 main(int argc, char ** argv)
60 BOOL result;
61 OSVERSIONINFO oiv;
63 /* FIXME: GetVersionEx() is a Win32 API call, so there should be a
64 preliminary check to see if we're running bare-bones Windows3.xx
65 (or even lower?). 19990916 mortene. */
67 oiv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
68 result = GetVersionEx(&oiv);
70 if (result == FALSE) {
71 show_last_error();
73 else {
74 char * platforms[] = {
75 "Win32s on Windows 3.1",
76 "Win32 on Windows 95 or Windows 98",
77 "Win32 on Windows NT/Windows 2000",
78 "unknown!"
80 int platformval = 3;
82 switch (oiv.dwPlatformId) {
83 case VER_PLATFORM_WIN32s: platformval = 0; break;
84 case VER_PLATFORM_WIN32_WINDOWS: platformval = 1; break;
85 case VER_PLATFORM_WIN32_NT: platformval = 2; break;
88 fprintf(stdout,
89 "MajorVersion: %ld\nMinorVersion: %ld\nBuildNumber: 0x%lx\n"
90 "Platform: %s\nCSDVersion: '%s'\n",
91 oiv.dwMajorVersion, oiv.dwMinorVersion, oiv.dwBuildNumber,
92 platforms[platformval], oiv.szCSDVersion);
95 return 0;