Added mappings for a few messages.
[wine] / programs / osversioncheck / osversioncheck.c
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).
5  *
6  * Copyright 1999 by Morten Eriksen <mailto:mortene@sim.no>
7  *
8  */
9
10 #include <windows.h>
11 #include <winbase.h>
12 #include <stdio.h>
13
14 void
15 show_last_error(void)
16 {
17   DWORD lasterr;
18   LPTSTR buffer;
19   BOOL result;
20
21   lasterr = GetLastError();
22
23   result = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
24                          FORMAT_MESSAGE_FROM_SYSTEM |
25                          FORMAT_MESSAGE_IGNORE_INSERTS,
26                          NULL,
27                          lasterr,
28                          0,
29                          (LPTSTR)&buffer,
30                          0,
31                          NULL);
32
33   if (result) {
34     fprintf(stderr, "Win32 API error (%ld):\t%s", lasterr, buffer);
35     LocalFree((HLOCAL)buffer);
36   }
37   else {
38     fprintf(stderr, "Win32 API error (%ld)", lasterr);
39   }
40 }
41
42 int
43 wine_main(int argc, char ** argv)
44 {
45   BOOL result;
46   OSVERSIONINFO oiv;
47
48   /* FIXME: GetVersionEx() is a Win32 API call, so there should be a
49      preliminary check to see if we're running bare-bones Windows3.xx
50      (or even lower?). 19990916 mortene. */
51
52   oiv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
53   result = GetVersionEx(&oiv);
54
55   if (result == FALSE) {
56     show_last_error();
57   }
58   else {
59     char * platforms[] = {
60       "Win32s on Windows 3.1",
61       "Win32 on Windows 95 or Windows 98",
62       "Win32 on Windows NT/Windows 2000",
63       "unknown!"
64     };
65     int platformval = 3;
66
67     switch (oiv.dwPlatformId) {
68     case VER_PLATFORM_WIN32s: platformval = 0; break;
69     case VER_PLATFORM_WIN32_WINDOWS: platformval = 1; break;
70     case VER_PLATFORM_WIN32_NT: platformval = 2; break;
71     }
72
73     fprintf(stdout,
74             "MajorVersion: %ld\nMinorVersion: %ld\nBuildNumber: 0x%lx\n"
75             "Platform: %s\nCSDVersion: '%s'\n",
76             oiv.dwMajorVersion, oiv.dwMinorVersion, oiv.dwBuildNumber,
77             platforms[platformval], oiv.szCSDVersion);
78   }
79
80   return 0;
81 }