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
25 #include "wine/port.h"
32 #define WIN32_NO_STATUS
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ver);
45 /***********************************************************************
46 * GetVersion (KERNEL32.@)
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;
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);
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;
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);
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 );
156 case STATUS_REVISION_MISMATCH:
157 SetLastError( ERROR_OLD_WIN_VERSION );
163 /***********************************************************************
164 * TermsrvAppInstallMode (KERNEL32.@)
166 * Find out whether the terminal server is in INSTALL or EXECUTE mode.
168 BOOL WINAPI TermsrvAppInstallMode(void)
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);