ReactOS 0.4.16-dev-306-g647d351
ver.c
Go to the documentation of this file.
1/*
2 * VER.C - ver internal command.
3 *
4 *
5 * History:
6 *
7 * 06/30/98 (Rob Lake)
8 * rewrote ver command to accept switches, now ver alone prints
9 * copyright notice only.
10 *
11 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
12 * added config.h include
13 *
14 * 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
15 * added text about where to send bug reports and get updates.
16 *
17 * 20-Jan-1999 (Eric Kohl)
18 * Unicode and redirection safe!
19 *
20 * 26-Feb-1999 (Eric Kohl)
21 * New version info and some output changes.
22 */
23
24#include "precomp.h"
25#include <reactos/buildno.h>
26#include <reactos/version.h>
27
29TCHAR szOSName[50] = _T("");
30
31
33{
34 LONG lResult;
35 HKEY hKey;
36
37 /* Get version information */
38 ZeroMemory(&osvi, sizeof(osvi));
41
42 /* Build OS version string */
43
44 /* Open registry key */
46 _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
47 0,
49 &hKey);
50 if (lResult == ERROR_SUCCESS)
51 {
52 DWORD dwSize, dwType;
53
54 /* Retrieve the ProductName value */
55 dwSize = sizeof(szOSName);
56 lResult = RegQueryValueEx(hKey,
57 _T("ProductName"),
58 NULL,
59 &dwType,
61 &dwSize);
62
63 /* If we have failed or the data type is unsupported... */
64 if (lResult != ERROR_SUCCESS || dwType != REG_SZ)
65 {
66 /* ... reserve size for one NULL character only! */
67 dwSize = sizeof(TCHAR);
68
69 /* Set an error code (anything != ERROR_SUCCESS) */
71 }
72
73 /* NULL-terminate the string */
74 szOSName[(dwSize / sizeof(TCHAR)) - 1] = _T('\0');
75
76 /* Close the key */
78 }
79
80 /*
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.
83 */
84 if (lResult != ERROR_SUCCESS)
85 {
86 switch (osvi.dwPlatformId)
87 {
89 {
90 if (osvi.dwMajorVersion == 4)
91 {
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"));
98 else
99 _tcscpy(szOSName, _T("Windows 9x"));
100 }
101 break;
102 }
103
105 {
106 _tcscpy(szOSName, _T("Windows NT"));
107 break;
108 }
109 }
110 }
111}
112
113/* Print the current OS version, suitable for VER command and PROMPT $V format */
115{
119}
120
121#ifdef INCLUDE_CMD_VER
122
123/*
124 * display shell version info internal command.
125 */
127{
128 INT i;
129
130 nErrorLevel = 0;
131
132 if (_tcsstr(param, _T("/?")) != NULL)
133 {
135 return 0;
136 }
137
138 ConOutResPrintf(STRING_CMD_SHELLINFO, _T(KERNEL_VERSION_STR), _T(KERNEL_VERSION_BUILD_STR));
139 ConOutChar(_T('\n'));
142
143 /* Basic copyright notice */
144 if (param[0] != _T('\0'))
145 {
146 ConOutPuts(_T("\n\n"));
147 ConOutPuts(_T("Copyright (C) 1994-1998 Tim Norman and others.\n"));
148 ConOutResPrintf(STRING_CMD_COPYRIGHT, _T(COPYRIGHT_YEAR));
149
150 for (i = 0; param[i]; i++)
151 {
152 /* Skip spaces */
153 if (param[i] == _T(' '))
154 continue;
155
156 if (param[i] == _T('/'))
157 {
158 /* Is this a lone '/' ? */
159 if (param[i + 1] == 0)
160 {
162 return 1;
163 }
164 continue;
165 }
166
167 if (_totupper(param[i]) == _T('W'))
168 {
169 /* Warranty notice */
171 }
172 else if (_totupper(param[i]) == _T('R'))
173 {
174 /* Redistribution notice */
176 }
177 else if (_totupper(param[i]) == _T('C'))
178 {
179 /* Developer listing */
184 }
185 else
186 {
188 return 1;
189 }
190 }
191
192 /* Bug report notice */
194 }
195
196 ConOutChar(_T('\n'));
197
198 return 0;
199}
200
201#endif
INT nErrorLevel
Definition: cmd.c:158
VOID error_invalid_switch(TCHAR ch)
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:178
#define ConOutPuts(szStr)
Definition: console.h:29
#define STRING_VERSION_RUNNING_ON
Definition: resource.h:199
#define STRING_VERSION_HELP6
Definition: resource.h:197
#define STRING_VERSION_RUNVER
Definition: resource.h:200
#define STRING_VERSION_HELP7
Definition: resource.h:198
#define STRING_VERSION_HELP1
Definition: resource.h:192
#define STRING_VERSION_HELP3
Definition: resource.h:194
#define STRING_CMD_SHELLINFO
Definition: resource.h:91
#define STRING_FREEDOS_DEV
Definition: resource.h:233
#define STRING_REACTOS_DEV
Definition: resource.h:234
#define STRING_CMD_COPYRIGHT
Definition: resource.h:89
#define STRING_VERSION_HELP5
Definition: resource.h:196
#define STRING_VERSION_HELP4
Definition: resource.h:195
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _tcscpy
Definition: tchar.h:623
#define _totupper
Definition: tchar.h:1509
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:238
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:237
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
long LONG
Definition: pedump.c:60
VOID ConOutChar(TCHAR c)
Definition: util.c:233
#define ConOutResPrintf(uID,...)
Definition: replace.h:31
#define ConOutResPuts(uID)
Definition: replace.h:28
static void PrintOSVersion(void)
Definition: rosperf.c:291
CHAR szCSDVersion[128]
Definition: rtltypes.h:242
ULONG dwPlatformId
Definition: rtltypes.h:241
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwBuildNumber
Definition: rtltypes.h:240
ULONG dwMinorVersion
Definition: rtltypes.h:239
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
TCHAR szOSName[50]
Definition: ver.c:29
INT cmd_ver(LPTSTR param)
Definition: ver.c:126
VOID InitOSVersion(VOID)
Definition: ver.c:32
OSVERSIONINFO osvi
Definition: ver.c:28
#define _T(x)
Definition: vfdio.h:22
#define ZeroMemory
Definition: winbase.h:1737
#define GetVersionEx
Definition: winbase.h:3877
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:306
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcsstr
Definition: xmlstorage.h:199