2 * VER.C - ver internal command.
8 * rewrote ver command to accept switches, now ver alone prints
9 * copyright notice only.
11 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
12 * added config.h include
14 * 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
15 * added text about where to send bug reports and get updates.
17 * 20-Jan-1999 (Eric Kohl)
18 * Unicode and redirection safe!
20 * 26-Feb-1999 (Eric Kohl)
21 * New version info and some output changes.
25 #include <reactos/buildno.h>
26 #include <reactos/version.h>
29 TCHAR szOSName
[50] = _T("");
32 VOID
InitOSVersion(VOID
)
37 /* Get version information */
38 ZeroMemory(&osvi
, sizeof(osvi
));
39 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
42 /* Build OS version string */
44 /* Open registry key */
45 lResult
= RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
46 _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
50 if (lResult
== ERROR_SUCCESS
)
54 /* Retrieve the ProductName value */
55 dwSize
= sizeof(szOSName
);
56 lResult
= RegQueryValueEx(hKey
,
63 /* If we have failed or the data type is unsupported... */
64 if (lResult
!= ERROR_SUCCESS
|| dwType
!= REG_SZ
)
66 /* ... reserve size for one NULL character only! */
67 dwSize
= sizeof(TCHAR
);
69 /* Set an error code (anything != ERROR_SUCCESS) */
70 lResult
= ERROR_INVALID_PARAMETER
;
73 /* NULL-terminate the string */
74 szOSName
[(dwSize
/ sizeof(TCHAR
)) - 1] = _T('\0');
81 * If the registry key somehow doesn't exist or cannot be loaded, then
82 * determine at least whether the version of Windows is either 9x or NT.
84 if (lResult
!= ERROR_SUCCESS
)
86 switch (osvi
.dwPlatformId
)
88 case VER_PLATFORM_WIN32_WINDOWS
:
90 if (osvi
.dwMajorVersion
== 4)
92 if (osvi
.dwMinorVersion
== 0)
93 _tcscpy(szOSName
, _T("Windows 95"));
94 else if (osvi
.dwMinorVersion
== 1)
95 _tcscpy(szOSName
, _T("Windows 98"));
96 else if (osvi
.dwMinorVersion
== 9)
97 _tcscpy(szOSName
, _T("Windows ME"));
99 _tcscpy(szOSName
, _T("Windows 9x"));
104 case VER_PLATFORM_WIN32_NT
:
106 _tcscpy(szOSName
, _T("Windows NT"));
113 /* Print the current OS version, suitable for VER command and PROMPT $V format */
114 VOID
PrintOSVersion(VOID
)
116 ConOutResPrintf(STRING_VERSION_RUNVER
, szOSName
,
117 osvi
.dwMajorVersion
, osvi
.dwMinorVersion
,
118 osvi
.dwBuildNumber
, osvi
.szCSDVersion
);
121 #ifdef INCLUDE_CMD_VER
124 * display shell version info internal command.
126 INT
cmd_ver (LPTSTR param
)
132 if (_tcsstr(param
, _T("/?")) != NULL
)
134 ConOutResPaging(TRUE
,STRING_VERSION_HELP1
);
138 ConOutResPrintf(STRING_CMD_SHELLINFO
, _T(KERNEL_VERSION_STR
), _T(KERNEL_VERSION_BUILD_STR
));
139 ConOutChar(_T('\n'));
140 ConOutResPuts(STRING_VERSION_RUNNING_ON
);
143 /* Basic copyright notice */
144 if (param
[0] != _T('\0'))
146 ConOutPuts(_T("\n\n"));
147 ConOutPuts(_T("Copyright (C) 1994-1998 Tim Norman and others.\n"));
148 ConOutPuts(_T("Copyright (C) 1998-") _T(COPYRIGHT_YEAR
) _T(" ReactOS Team\n"));
150 for (i
= 0; param
[i
]; i
++)
153 if (param
[i
] == _T(' '))
156 if (param
[i
] == _T('/'))
158 /* Is this a lone '/' ? */
159 if (param
[i
+ 1] == 0)
161 error_invalid_switch(_T(' '));
167 if (_totupper(param
[i
]) == _T('W'))
169 /* Warranty notice */
170 ConOutResPuts(STRING_VERSION_HELP3
);
172 else if (_totupper(param
[i
]) == _T('R'))
174 /* Redistribution notice */
175 ConOutResPuts(STRING_VERSION_HELP4
);
177 else if (_totupper(param
[i
]) == _T('C'))
179 /* Developer listing */
180 ConOutResPuts(STRING_VERSION_HELP6
);
181 ConOutResPuts(STRING_FREEDOS_DEV
);
182 ConOutResPuts(STRING_VERSION_HELP7
);
183 ConOutResPuts(STRING_REACTOS_DEV
);
187 error_invalid_switch(_totupper(param
[i
]));
192 /* Bug report notice */
193 ConOutResPuts(STRING_VERSION_HELP5
);
196 ConOutChar(_T('\n'));