ReactOS  0.4.14-dev-608-gd495a4f
ver.c File Reference
#include "precomp.h"
#include <reactos/buildno.h>
#include <reactos/version.h>
Include dependency graph for ver.c:

Go to the source code of this file.

Functions

VOID InitOSVersion (VOID)
 
VOID PrintOSVersion (VOID)
 
INT cmd_ver (LPTSTR param)
 

Variables

OSVERSIONINFO osvi
 
TCHAR szOSName [50] = _T("")
 

Function Documentation

◆ cmd_ver()

INT cmd_ver ( LPTSTR  param)

Definition at line 126 of file ver.c.

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'));
141  PrintOSVersion();
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  ConOutPuts(_T("Copyright (C) 1998-") _T(COPYRIGHT_YEAR) _T(" ReactOS Team\n"));
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  {
161  error_invalid_switch(_T(' '));
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 }
#define STRING_CMD_SHELLINFO
Definition: resource.h:90
INT nErrorLevel
Definition: cmd.c:157
#define TRUE
Definition: types.h:120
#define STRING_VERSION_HELP4
Definition: resource.h:193
#define STRING_REACTOS_DEV
Definition: resource.h:244
#define STRING_VERSION_HELP3
Definition: resource.h:192
VOID ConOutChar(TCHAR c)
Definition: console.c:123
#define STRING_VERSION_HELP5
Definition: resource.h:194
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
#define _totupper
Definition: tchar.h:1509
int32_t INT
Definition: typedefs.h:56
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
smooth NULL
Definition: ftsmooth.c:416
#define _tcsstr
Definition: xmlstorage.h:199
#define STRING_VERSION_HELP1
Definition: resource.h:190
#define _T(x)
Definition: vfdio.h:22
#define STRING_VERSION_HELP7
Definition: resource.h:196
GLfloat param
Definition: glext.h:5796
#define STRING_FREEDOS_DEV
Definition: resource.h:243
#define ConOutResPrintf(uID,...)
Definition: console.h:48
VOID error_invalid_switch(TCHAR)
Definition: error.c:70
VOID PrintOSVersion(VOID)
Definition: ver.c:114
#define STRING_VERSION_RUNNING_ON
Definition: resource.h:197
#define ConOutResPuts(uID)
Definition: console.h:36
#define STRING_VERSION_HELP6
Definition: resource.h:195
VOID ConOutPuts(LPTSTR szText)
Definition: tee.c:27

◆ InitOSVersion()

VOID InitOSVersion ( VOID  )

Definition at line 32 of file ver.c.

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) */
70  lResult = ERROR_INVALID_PARAMETER;
71  }
72 
73  /* NULL-terminate the string */
74  szOSName[(dwSize / sizeof(TCHAR)) - 1] = _T('\0');
75 
76  /* Close the key */
77  RegCloseKey(hKey);
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 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:236
ULONG dwMajorVersion
Definition: rtltypes.h:234
#define ERROR_SUCCESS
Definition: deptool.c:10
OSVERSIONINFO osvi
Definition: ver.c:28
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1642
TCHAR szOSName[50]
Definition: ver.c:29
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:289
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG dwMinorVersion
Definition: rtltypes.h:235
#define RegOpenKeyEx
Definition: winreg.h:520
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
ULONG dwPlatformId
Definition: rtltypes.h:237
#define GetVersionEx
Definition: winbase.h:3686
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:235
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by Initialize().

◆ PrintOSVersion()

VOID PrintOSVersion ( VOID  )

Definition at line 114 of file ver.c.

115 {
119 }
ULONG dwMajorVersion
Definition: rtltypes.h:234
OSVERSIONINFO osvi
Definition: ver.c:28
TCHAR szOSName[50]
Definition: ver.c:29
ULONG dwBuildNumber
Definition: rtltypes.h:236
#define ConOutResPrintf(uID,...)
Definition: console.h:48
ULONG dwMinorVersion
Definition: rtltypes.h:235
CHAR szCSDVersion[128]
Definition: rtltypes.h:238
#define STRING_VERSION_RUNVER
Definition: resource.h:198

Referenced by cmd_ver(), and PrintPrompt().

Variable Documentation

◆ osvi

◆ szOSName

TCHAR szOSName[50] = _T("")

Definition at line 29 of file ver.c.

Referenced by InitializeSystemPage(), InitOSVersion(), and PrintOSVersion().