reg: Do not allow duplicate /d or /t switches.
[wine.git] / dlls / kernel32 / version.c
blobb9d13e42813ab66c6e5ba0df85903b958c91883e
1 /*
2 * Windows and DOS version functions
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Patrik Stridvall
6 * Copyright 1998, 2003 Andreas Mohr
7 * Copyright 1997, 2003 Alexandre Julliard
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include "ntstatus.h"
32 #define WIN32_NO_STATUS
33 #include "windef.h"
34 #include "winbase.h"
35 #include "wingdi.h"
36 #include "winuser.h"
37 #include "winternl.h"
38 #include "winerror.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ver);
45 /***********************************************************************
46 * GetVersion (KERNEL32.@)
48 * Win31 0x80000a03
49 * Win95 0xc0000004
50 * Win98 0xc0000a04
51 * WinME 0xc0005a04
52 * NT351 0x04213303
53 * NT4 0x05650004
54 * Win2000 0x08930005
55 * WinXP 0x0a280105
57 DWORD WINAPI GetVersion(void)
59 DWORD result = MAKELONG( MAKEWORD( NtCurrentTeb()->Peb->OSMajorVersion,
60 NtCurrentTeb()->Peb->OSMinorVersion ),
61 (NtCurrentTeb()->Peb->OSPlatformId ^ 2) << 14 );
62 if (NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32_NT)
63 result |= LOWORD(NtCurrentTeb()->Peb->OSBuildNumber) << 16;
64 return result;
68 /***********************************************************************
69 * GetVersionExA (KERNEL32.@)
71 BOOL WINAPI GetVersionExA(OSVERSIONINFOA *v)
73 RTL_OSVERSIONINFOEXW infoW;
75 if (v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA) &&
76 v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA))
78 WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
79 v->dwOSVersionInfoSize );
80 SetLastError(ERROR_INSUFFICIENT_BUFFER);
81 return FALSE;
84 infoW.dwOSVersionInfoSize = sizeof(infoW);
85 if (RtlGetVersion( &infoW ) != STATUS_SUCCESS) return FALSE;
87 v->dwMajorVersion = infoW.dwMajorVersion;
88 v->dwMinorVersion = infoW.dwMinorVersion;
89 v->dwBuildNumber = infoW.dwBuildNumber;
90 v->dwPlatformId = infoW.dwPlatformId;
91 WideCharToMultiByte( CP_ACP, 0, infoW.szCSDVersion, -1,
92 v->szCSDVersion, sizeof(v->szCSDVersion), NULL, NULL );
94 if(v->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
96 LPOSVERSIONINFOEXA vex = (LPOSVERSIONINFOEXA) v;
97 vex->wServicePackMajor = infoW.wServicePackMajor;
98 vex->wServicePackMinor = infoW.wServicePackMinor;
99 vex->wSuiteMask = infoW.wSuiteMask;
100 vex->wProductType = infoW.wProductType;
102 return TRUE;
106 /***********************************************************************
107 * GetVersionExW (KERNEL32.@)
109 BOOL WINAPI GetVersionExW( OSVERSIONINFOW *info )
111 if (info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
112 info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
114 WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
115 info->dwOSVersionInfoSize);
116 return FALSE;
118 return (RtlGetVersion( (RTL_OSVERSIONINFOEXW *)info ) == STATUS_SUCCESS);
122 /******************************************************************************
123 * VerifyVersionInfoA (KERNEL32.@)
125 BOOL WINAPI VerifyVersionInfoA( LPOSVERSIONINFOEXA lpVersionInfo, DWORD dwTypeMask,
126 DWORDLONG dwlConditionMask)
128 OSVERSIONINFOEXW verW;
130 verW.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
131 verW.dwMajorVersion = lpVersionInfo->dwMajorVersion;
132 verW.dwMinorVersion = lpVersionInfo->dwMinorVersion;
133 verW.dwBuildNumber = lpVersionInfo->dwBuildNumber;
134 verW.dwPlatformId = lpVersionInfo->dwPlatformId;
135 verW.wServicePackMajor = lpVersionInfo->wServicePackMajor;
136 verW.wServicePackMinor = lpVersionInfo->wServicePackMinor;
137 verW.wSuiteMask = lpVersionInfo->wSuiteMask;
138 verW.wProductType = lpVersionInfo->wProductType;
139 verW.wReserved = lpVersionInfo->wReserved;
141 return VerifyVersionInfoW(&verW, dwTypeMask, dwlConditionMask);
145 /******************************************************************************
146 * VerifyVersionInfoW (KERNEL32.@)
148 BOOL WINAPI VerifyVersionInfoW( LPOSVERSIONINFOEXW lpVersionInfo, DWORD dwTypeMask,
149 DWORDLONG dwlConditionMask)
151 switch(RtlVerifyVersionInfo( lpVersionInfo, dwTypeMask, dwlConditionMask ))
153 case STATUS_INVALID_PARAMETER:
154 SetLastError( ERROR_BAD_ARGUMENTS );
155 return FALSE;
156 case STATUS_REVISION_MISMATCH:
157 SetLastError( ERROR_OLD_WIN_VERSION );
158 return FALSE;
160 return TRUE;
163 /***********************************************************************
164 * TermsrvAppInstallMode (KERNEL32.@)
166 * Find out whether the terminal server is in INSTALL or EXECUTE mode.
168 BOOL WINAPI TermsrvAppInstallMode(void)
170 FIXME("stub\n");
171 return FALSE;
174 /***********************************************************************
175 * SetTermsrvAppInstallMode (KERNEL32.@)
177 * This function is said to switch between the INSTALL (TRUE) or
178 * EXECUTE (FALSE) terminal server modes.
180 * This function always returns zero on WinXP Home so it's probably
181 * safe to return that value in most cases. However, if a terminal
182 * server is running it will probably return something else.
184 DWORD WINAPI SetTermsrvAppInstallMode(BOOL bInstallMode)
186 FIXME("(%d): stub\n", bInstallMode);
187 return 0;
190 /***********************************************************************
191 * GetProductInfo (KERNEL32.@)
193 * Gives info about the current Windows product type, in a format compatible
194 * with the given Windows version
196 * Returns TRUE if the input is valid, FALSE otherwise
198 BOOL WINAPI GetProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion,
199 DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType)
201 return RtlGetProductInfo(dwOSMajorVersion, dwOSMinorVersion,
202 dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType);
205 LONG WINAPI GetCurrentPackageId(UINT32 *len, BYTE *buffer)
207 FIXME("(%p %p): stub\n", len, buffer);
208 return APPMODEL_ERROR_NO_PACKAGE;