ReactOS 0.4.16-dev-927-g467dec4
osinfo.c File Reference
#include "winver_p.h"
Include dependency graph for osinfo.c:

Go to the source code of this file.

Macros

#define OSINFO_KEY   L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
 

Functions

static VOID Winver_GetRegValueString (_In_ HKEY hKey, _In_ LPCWSTR pValue, _Out_ LPWSTR pBuffer, _In_ DWORD cchSize)
 
static VOID Winver_GetFormattedSpkInfo (_In_ HKEY hKey, _Out_ LPWSTR pBuffer, _In_ DWORD cchSize)
 
static VOID Winver_FormatCompatInfo (_In_ HKEY hKey, _Out_ LPWSTR pBuffer, _In_ DWORD cchSize)
 
BOOL Winver_GetOSInfo (_Out_ PWINVER_OS_INFO OSInfo)
 

Macro Definition Documentation

◆ OSINFO_KEY

#define OSINFO_KEY   L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"

Definition at line 10 of file osinfo.c.

Function Documentation

◆ Winver_FormatCompatInfo()

static VOID Winver_FormatCompatInfo ( _In_ HKEY  hKey,
_Out_ LPWSTR  pBuffer,
_In_ DWORD  cchSize 
)
static

Definition at line 65 of file osinfo.c.

69{
70 WCHAR szNtVersion[16];
71 WCHAR szNtBuild[16];
72 WCHAR szNtSpk[64];
73 WCHAR szFormat[64] = L"";
74
75 /* NOTE: Required info must be valid */
76 Winver_GetRegValueString(hKey, L"CurrentVersion", szNtVersion, _countof(szNtVersion));
77 Winver_GetRegValueString(hKey, L"CurrentBuildNumber", szNtBuild, _countof(szNtBuild));
78 if (!szNtVersion[0] || !szNtBuild[0])
79 {
80 /* Return empty string on failure */
82 return;
83 }
84
85 /* NOTE: Service pack info is optional */
86 Winver_GetFormattedSpkInfo(hKey, szNtSpk, _countof(szNtSpk));
87
90 szFormat,
91 _countof(szFormat));
92
93 StringCchPrintfW(pBuffer, cchSize, szFormat, szNtVersion, szNtBuild, szNtSpk);
94}
#define IDS_OSINFO_COMPAT_FORMAT
Definition: resource.h:10
FxAutoRegKey hKey
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
static VOID Winver_GetRegValueString(_In_ HKEY hKey, _In_ LPCWSTR pValue, _Out_ LPWSTR pBuffer, _In_ DWORD cchSize)
Definition: osinfo.c:14
static VOID Winver_GetFormattedSpkInfo(_In_ HKEY hKey, _Out_ LPWSTR pBuffer, _In_ DWORD cchSize)
Definition: osinfo.c:39
PVOID pBuffer
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE Winver_hInstance
Definition: winver.c:9
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Winver_GetOSInfo().

◆ Winver_GetFormattedSpkInfo()

static VOID Winver_GetFormattedSpkInfo ( _In_ HKEY  hKey,
_Out_ LPWSTR  pBuffer,
_In_ DWORD  cchSize 
)
static

Definition at line 39 of file osinfo.c.

43{
44 WCHAR szRegValue[48];
45 WCHAR szFormat[16] = L"";
46
47 Winver_GetRegValueString(hKey, L"CSDVersion", szRegValue, _countof(szRegValue));
48 if (!szRegValue[0])
49 {
50 /* Return empty string on failure */
52 return;
53 }
54
57 szFormat,
58 _countof(szFormat));
59
60 StringCchPrintfW(pBuffer, cchSize, szFormat, szRegValue);
61}
#define IDS_OSINFO_SPK_FORMAT
Definition: resource.h:11

Referenced by Winver_FormatCompatInfo().

◆ Winver_GetOSInfo()

BOOL Winver_GetOSInfo ( _Out_ PWINVER_OS_INFO  OSInfo)

Definition at line 97 of file osinfo.c.

99{
100 HKEY hKey;
101 LSTATUS lError;
102
105 0,
107 &hKey);
108 if (lError != ERROR_SUCCESS)
109 return FALSE;
110
111 /* OS name */
112 Winver_GetRegValueString(hKey, L"ProductName", OSInfo->szName, _countof(OSInfo->szName));
113 if (!OSInfo->szName[0])
114 {
115 /* This info must be valid */
117 return FALSE;
118 }
119
120 /* Compatibility information */
121 Winver_FormatCompatInfo(hKey, OSInfo->szCompatInfo, _countof(OSInfo->szCompatInfo));
122
124
125 return TRUE;
126}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define OSINFO_KEY
Definition: osinfo.c:10
static VOID Winver_FormatCompatInfo(_In_ HKEY hKey, _Out_ LPWSTR pBuffer, _In_ DWORD cchSize)
Definition: osinfo.c:65
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by wWinMain().

◆ Winver_GetRegValueString()

static VOID Winver_GetRegValueString ( _In_ HKEY  hKey,
_In_ LPCWSTR  pValue,
_Out_ LPWSTR  pBuffer,
_In_ DWORD  cchSize 
)
static

Definition at line 14 of file osinfo.c.

19{
20 DWORD dwType, dwSize;
21 LSTATUS lError;
22
23 /* NOTE: Reserved space for a NULL terminator */
24 dwSize = (cchSize - 1) * sizeof(WCHAR);
25 lError = RegQueryValueExW(hKey, pValue, NULL, &dwType, (LPBYTE)pBuffer, &dwSize);
26 if (lError != ERROR_SUCCESS || dwType != REG_SZ)
27 {
28 /* Return empty string on failure */
30 return;
31 }
32
33 /* Ensure the returned string is NULL terminated */
34 pBuffer[cchSize - 1] = UNICODE_NULL;
35}
#define NULL
Definition: types.h:112
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
PWCHAR pValue
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by Winver_FormatCompatInfo(), Winver_GetFormattedSpkInfo(), and Winver_GetOSInfo().