Started implementation of the functions GetDefaultCommConfigA/W.
[wine.git] / programs / osversioncheck / osversioncheck.c
blobf7c1ddd65809a4f719a302dee622747265ae0ef3
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>
8 */
10 #include <windows.h>
11 #include <winbase.h>
12 #include <stdio.h>
14 void
15 show_last_error(void)
17 DWORD lasterr;
18 LPTSTR buffer;
19 BOOL result;
21 lasterr = GetLastError();
23 result = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
24 FORMAT_MESSAGE_FROM_SYSTEM |
25 FORMAT_MESSAGE_IGNORE_INSERTS,
26 NULL,
27 lasterr,
29 (LPTSTR)&buffer,
31 NULL);
33 if (result) {
34 fprintf(stderr, "Win32 API error (%ld):\t%s", lasterr, buffer);
35 LocalFree((HLOCAL)buffer);
37 else {
38 fprintf(stderr, "Win32 API error (%ld)", lasterr);
42 int
43 wine_main(int argc, char ** argv)
45 BOOL result;
46 OSVERSIONINFO oiv;
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. */
52 oiv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
53 result = GetVersionEx(&oiv);
55 if (result == FALSE) {
56 show_last_error();
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!"
65 int platformval = 3;
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;
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);
80 return 0;