Release 20000326.
[wine/gsoc-2012-control.git] / programs / osversioncheck / osversioncheck.c
blobfd8510f190d898ebf1e5c984c09f19c3da73e83a
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 #ifdef WINELIB
15 /* External declaration here because we don't want to depend on Wine's
16 internal headers. */
17 extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
18 #endif /* WINELIB */
21 void
22 show_last_error(void)
24 DWORD lasterr;
25 LPTSTR buffer;
26 BOOL result;
28 lasterr = GetLastError();
30 result = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
31 FORMAT_MESSAGE_FROM_SYSTEM |
32 FORMAT_MESSAGE_IGNORE_INSERTS,
33 NULL,
34 lasterr,
36 (LPTSTR)&buffer,
38 NULL);
40 if (result) {
41 fprintf(stderr, "Win32 API error (%ld):\t%s", lasterr, buffer);
42 LocalFree((HLOCAL)buffer);
44 else {
45 fprintf(stderr, "Win32 API error (%ld)", lasterr);
49 int
50 main(int argc, char ** argv)
52 BOOL result;
53 OSVERSIONINFO oiv;
54 HINSTANCE hinst;
56 #ifdef WINELIB
57 if (!(hinst = MAIN_WinelibInit(&argc, argv))) return 0;
58 #endif /* WINELIB */
60 /* FIXME: GetVersionEx() is a Win32 API call, so there should be a
61 preliminary check to see if we're running bare-bones Windows3.xx
62 (or even lower?). 19990916 mortene. */
64 oiv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
65 result = GetVersionEx(&oiv);
67 if (result == FALSE) {
68 show_last_error();
70 else {
71 char * platforms[] = {
72 "Win32s on Windows 3.1",
73 "Win32 on Windows 95 or Windows 98",
74 "Win32 on Windows NT/Windows 2000",
75 "unknown!"
77 int platformval = 3;
79 switch (oiv.dwPlatformId) {
80 case VER_PLATFORM_WIN32s: platformval = 0; break;
81 case VER_PLATFORM_WIN32_WINDOWS: platformval = 1; break;
82 case VER_PLATFORM_WIN32_NT: platformval = 2; break;
85 fprintf(stdout,
86 "MajorVersion: %ld\nMinorVersion: %ld\nBuildNumber: 0x%lx\n"
87 "Platform: %s\nCSDVersion: '%s'\n",
88 oiv.dwMajorVersion, oiv.dwMinorVersion, oiv.dwBuildNumber,
89 platforms[platformval], oiv.szCSDVersion);
92 return 0;