Ir para conteúdo
Fórum Script Brasil
  • 0

VERSÃO DO WINDOWS


Paulo Nobre

Pergunta

Com

WinVista := (Win32MajorVersion = 6) and (Win32Platform = VER_PLATFORM_WIN32_NT);

dá para verificar se estamos rodando no windows vista.

Alguém saberia dizer se com

Win7 := (Win32MajorVersion = 7) and (Win32Platform = VER_PLATFORM_WIN32_NT);

conseguiríamos descobrir se estamos rodando no windows 7?

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

Veja esta Unit .. voce consegue saber até o windows vista ... para os demais sistemas operacionais, voce vai precisar da ntdll.dll ( codigo no final desta unit )

unit 
 GetWinVersionInfo; 

type 
  _OSVERSIONINFOEX = record 
    dwOSVersionInfoSize : DWORD; 
    dwMajorVersion      : DWORD; 
    dwMinorVersion      : DWORD; 
    dwBuildNumber       : DWORD; 
    dwPlatformId        : DWORD; 
    szCSDVersion        : array[0..127] of AnsiChar; 
    wServicePackMajor   : WORD; 
    wServicePackMinor   : WORD; 
    wSuiteMask          : WORD; 
    wProductType        : BYTE; 
    wReserved           : BYTE; 
  end; 
  TOSVERSIONINFOEX = _OSVERSIONINFOEX; 

  function GetVersionExA(var lpVersionInformation: TOSVersionInfoEX): BOOL; 
        stdcall; external kernel32; 

const 
  VER_NT_WORKSTATION    :Integer = 1; 
  VER_SUITE_ENTERPRISE  :Integer = 2; 
  VER_NT_SERVER         :Integer = 3; 
  VER_SUITE_DATACENTER  :Integer = 128; 
  VER_SUITE_PERSONAL    :Integer = 512; 

const 
  PRODUCT_BUSINESS                      = $00000006; {Business Edition} 
  PRODUCT_BUSINESS_N                    = $00000010; {Business Edition} 
  PRODUCT_CLUSTER_SERVER                = $00000012; {Cluster Server Edition} 
  PRODUCT_DATACENTER_SERVER             = $00000008; {Server Datacenter Edition 
(full installation)} 
  PRODUCT_DATACENTER_SERVER_CORE        = $0000000C; {Server Datacenter Edition 
(core installation)} 
  PRODUCT_ENTERPRISE                    = $00000004; {Enterprise Edition} 
  PRODUCT_ENTERPRISE_N                  = $0000001B; {Enterprise Edition} 
  PRODUCT_ENTERPRISE_SERVER             = $0000000A; {Server Enterprise Edition 
(full installation)} 
  PRODUCT_ENTERPRISE_SERVER_CORE        = $0000000E; {Server Enterprise Edition 
(core installation)} 
  PRODUCT_ENTERPRISE_SERVER_IA64        = $0000000F; {Server Enterprise Edition 
for Itanium-based Systems} 
  PRODUCT_HOME_BASIC                    = $00000002; {Home Basic Edition} 
  PRODUCT_HOME_BASIC_N                  = $00000005; {Home Basic Edition} 
  PRODUCT_HOME_PREMIUM                  = $00000003; {Home Premium Edition} 
  PRODUCT_HOME_PREMIUM_N                = $0000001A; {Home Premium Edition} 
  PRODUCT_HOME_SERVER                   = $00000013; {Home Server Edition} 
  PRODUCT_SERVER_FOR_SMALLBUSINESS      = $00000018; {Server for Small Business 
Edition} 
  PRODUCT_SMALLBUSINESS_SERVER          = $00000009; {Small Business Server} 
  PRODUCT_SMALLBUSINESS_SERVER_PREMIUM  = $00000019; {Small Business Server 
Premium Edition} 
  PRODUCT_STANDARD_SERVER               = $00000007; {Server Standard Edition 
(full installation)} 
  PRODUCT_STANDARD_SERVER_CORE          = $0000000D; {Server Standard Edition 
(core installation)} 
  PRODUCT_STARTER                       = $0000000B; {Starter Edition} 
  PRODUCT_STORAGE_ENTERPRISE_SERVER     = $00000017; {Storage Server Enterprise 
Edition} 
  PRODUCT_STORAGE_EXPRESS_SERVER        = $00000014; {Storage Server Express 
Edition} 
  PRODUCT_STORAGE_STANDARD_SERVER       = $00000015; {Storage Server Standard 
Edition} 
  PRODUCT_STORAGE_WORKGROUP_SERVER      = $00000016; {Storage Server Workgroup 
Edition} 
  PRODUCT_UNDEFINED                     = $00000000; {An unknown product} 
  PRODUCT_ULTIMATE                      = $00000001; {Ultimate Edition} 
  PRODUCT_ULTIMATE_N                    = $0000001C; {Ultimate Edition} 
  PRODUCT_WEB_SERVER                    = $00000011; {Web Server Edition} 
  PRODUCT_UNLICENSED                    = $ABCDABCD; {Unlicensed product} 

var 
{$EXTERNALSYM GetProductInfo} 
  GetProductInfo: function (dwOSMajorVersion, dwOSMinorVersion, 
                            dwSpMajorVersion, dwSpMinorVersion: DWORD; 
                            var pdwReturnedProductType: DWORD): BOOL stdcall = NIL; 

function GetOSInfo: string; 
var 
  NTBres, BRes: Boolean; 
  OSVI: TOSVERSIONINFO; 
  OSVI_NT: TOSVERSIONINFOEX; 
  tmpStr: string; 
  dwOSMajorVersion, dwOSMinorVersion, 
  dwSpMajorVersion, dwSpMinorVersion, 
  pdwReturnedProductType : DWORD; 
begin 
  Result := 'Error'; 
  NTBRes := FALSE; 
  try 
    OSVI_NT.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFOEX); 
    NTBRes := GetVersionExA(OSVI_NT); 
    OSVI.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); 
    BRes := GetVersionEx(OSVI); 
  except 
    OSVI.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); 
    BRes := GetVersionEx(OSVI); 
  end; 
  if (not BRes) and (not NTBres) then 
    Exit; 
  Move( OSVI, OSVI_NT, SizeOf(TOSVersionInfo) ); 

  case OSVI_NT.dwPlatformId of 
     VER_PLATFORM_WIN32_NT: 
       begin 
         if OSVI_NT.dwMajorVersion <= 4 then 
           Result := 'Windows NT '; 
         if (OSVI_NT.dwMajorVersion = 5) and (OSVI_NT.dwMinorVersion = 0) then 
           Result := 'Windows 2000 '; 
         if  (OSVI_NT.dwMajorVersion = 5) and (OSVI_NT.dwMinorVersion = 1) then 
           Result := 'Windows XP '; 
         if (OSVI_NT.dwMajorVersion = 6) and (OSVI_NT.dwMinorVersion = 0) then 
         begin 
           Result := 'Windows Vista '; 
           if Assigned(GetProductInfo) then 
           begin 
             GetProductInfo( dwOSMajorVersion, dwOSMinorVersion, 
                             dwSpMajorVersion, dwSpMinorVersion, 
                             pdwReturnedProductType ); 
             case pdwReturnedProductType of 
               PRODUCT_BUSINESS: 
                 tmpStr := 'Business Edition'; 
               PRODUCT_BUSINESS_N: 
                 tmpStr := 'Business Edition'; 
               PRODUCT_CLUSTER_SERVER: 
                 tmpStr := 'Cluster Server Edition'; 
               PRODUCT_DATACENTER_SERVER: 
                 tmpStr := 'Server Datacenter Edition (full installation)'; 
               PRODUCT_DATACENTER_SERVER_CORE: 
                 tmpStr := 'Server Datacenter Edition (core installation)'; 
               PRODUCT_ENTERPRISE: 
                 tmpStr := 'Enterprise Edition'; 
               PRODUCT_ENTERPRISE_N: 
                 tmpStr := 'Enterprise Edition'; 
               PRODUCT_ENTERPRISE_SERVER: 
                 tmpStr := 'Server Enterprise Edition (full installation)'; 
               PRODUCT_ENTERPRISE_SERVER_CORE: 
                 tmpStr := 'Server Enterprise Edition (core installation)'; 
               PRODUCT_ENTERPRISE_SERVER_IA64: 
                 tmpStr := 'Server Enterprise Edition for Itanium-based Systems'; 
               PRODUCT_HOME_BASIC: 
                 tmpStr := 'Home Basic Edition'; 
               PRODUCT_HOME_BASIC_N: 
                 tmpStr := 'Home Basic Edition'; 
               PRODUCT_HOME_PREMIUM: 
                 tmpStr := 'Home Premium Edition'; 
               PRODUCT_HOME_PREMIUM_N: 
                 tmpStr := 'Home Premium Edition'; 
               PRODUCT_HOME_SERVER: 
                 tmpStr := 'Home Server Edition'; 
               PRODUCT_SERVER_FOR_SMALLBUSINESS: 
                 tmpStr := 'Server for Small Business Edition'; 
               PRODUCT_SMALLBUSINESS_SERVER: 
                 tmpStr := 'Small Business Server'; 
               PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: 
                 tmpStr := 'Small Business Server Premium Edition'; 
               PRODUCT_STANDARD_SERVER: 
                 tmpStr := 'Server Standard Edition (full installation)'; 
               PRODUCT_STANDARD_SERVER_CORE: 
                 tmpStr := 'Server Standard Edition (core installation)'; 
               PRODUCT_STARTER: 
                 tmpStr := 'Starter Edition'; 
               PRODUCT_STORAGE_ENTERPRISE_SERVER: 
                 tmpStr := 'Storage Server Enterprise Edition'; 
               PRODUCT_STORAGE_EXPRESS_SERVER: 
                 tmpStr := 'Storage Server Express Edition'; 
               PRODUCT_STORAGE_STANDARD_SERVER: 
                 tmpStr := 'Storage Server Standard Edition'; 
               PRODUCT_STORAGE_WORKGROUP_SERVER: 
                 tmpStr := 'Storage Server Workgroup Edition'; 
               PRODUCT_UNDEFINED: 
                 tmpStr := 'An unknown product'; 
               PRODUCT_ULTIMATE: 
                 tmpStr := 'Ultimate Edition'; 
               PRODUCT_ULTIMATE_N: 
                 tmpStr := 'Ultimate Edition'; 
               PRODUCT_WEB_SERVER: 
                 tmpStr := 'Web Server Edition'; 
               PRODUCT_UNLICENSED: 
                 tmpStr := 'Unlicensed product' 
             else 
               tmpStr := ''; 
             end;{ pdwReturnedProductType } 
             Result := Result + tmpStr; 
             NTBRes := FALSE; 
           end;{ GetProductInfo<>NIL } 
         end;{ Vista } 
         if NTBres then 
         begin 
           if OSVI_NT.wProductType = VER_NT_WORKSTATION then 
           begin 
             if OSVI_NT.wProductType = VER_NT_WORKSTATION then 
             begin 
               case OSVI_NT.wSuiteMask of 
                 512: Result := Result + 'Personal'; 
                 768: Result := Result + 'Home Premium'; 
               else 
                 Result := Result + 'Professional'; 
               end; 
             end 
             else if OSVI_NT.wProductType = VER_NT_SERVER then 
             begin 
               if OSVI_NT.wSuiteMask = VER_SUITE_DATACENTER then 
                 Result := Result + 'DataCenter Server' 
               else if OSVI_NT.wSuiteMask = VER_SUITE_ENTERPRISE then 
                 Result :=  Result + 'Advanced Server' 
               else 
                 Result := Result + 'Server'; 
             end; 
           end{ wProductType=VER_NT_WORKSTATION } 
           else 
           begin 
             with TRegistry.Create do 
               try 
                 RootKey := HKEY_LOCAL_MACHINE; 
                 if OpenKeyReadOnly('SYSTEM\CurrentControlSet\Control\ProductOptions') then 
                   try 
                     tmpStr := UpperCase(ReadString('ProductType')); 
                     if tmpStr = 'WINNT' then 
                       Result := Result + 'Workstation'; 
                     if tmpStr = 'SERVERNT' then 
                       Result := Result + 'Server'; 
                   finally 
                     CloseKey; 
                   end; 
               finally 
                 Free; 
               end; 
             end;{ wProductType<>VER_NT_WORKSTATION } 
           end;{ NTBRes } 
         end;{ VER_PLATFORM_WIN32_NT } 
     VER_PLATFORM_WIN32_WINDOWS: 
       begin 
         if (OSVI.dwMajorVersion = 4) and (OSVI.dwMinorVersion = 0) then 
         begin 
           Result := 'Windows 95 '; 
           if OSVI.szCSDVersion[1] = 'C' then 
             Result := Result + 'OSR2'; 
         end; 
         if (OSVI.dwMajorVersion = 4) and (OSVI.dwMinorVersion = 10) then 
         begin 
           Result := 'Windows 98 '; 
           if OSVI.szCSDVersion[1] = 'A' then 
             Result := Result + 'SE'; 
         end; 
         if (OSVI.dwMajorVersion = 4) and (OSVI.dwMinorVersion = 90) then 
           Result := 'Windows Me'; 
       end;{ VER_PLATFORM_WIN32_WINDOWS } 
     VER_PLATFORM_WIN32s: 
       Result := 'Microsoft Win32s'; 
  else 
    Result := 'Unknown'; 
  end;{ OSVI_NT.dwPlatformId } 
end;{ GetOSInfo } 

initialization 
   @GetProductInfo := GetProcAddress(GetModuleHandle('KERNEL32.DLL'), 
                                     'GetProductInfo'); 

end.
========================================================================
1 /*
2 * Windows and DOS version functions
3 *
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Patrik Stridvall
6 * Copyright 1998, 2003 Andreas Mohr
7 * Copyright 1997, 2003 Alexandre Julliard
8 *
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.
13 *
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.
18 *
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
22 */
23 
24 #include "config.h"
25 #include "wine/port.h"
26 
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 "wine/unicode.h"
35 #include "wine/debug.h"
36 #include "ntdll_misc.h"
37 #include "ddk/wdm.h"
38 
39 WINE_DEFAULT_DEBUG_CHANNEL(ver);
40 
41 typedef enum
42 {
43 WIN20, /* Windows 2.0 */
44 WIN30, /* Windows 3.0 */
45 WIN31, /* Windows 3.1 */
46 WIN95, /* Windows 95 */
47 WIN98, /* Windows 98 */
48 WINME, /* Windows Me */
49 NT351, /* Windows NT 3.51 */
50 NT40, /* Windows NT 4.0 */
51 NT2K, /* Windows 2000 */
52 WINXP, /* Windows XP */
53 WIN2K3, /* Windows 2003 */
54 WINVISTA,/* Windows Vista */
55 WIN2K8, /* Windows 2008 */
56 WIN2K8R2,/* Windows 2008 R2 */
57 WIN7, /* Windows 7 */
58 NB_WINDOWS_VERSIONS
59 } WINDOWS_VERSION;
60 
61 /* FIXME: compare values below with original and fix.
62 * An *excellent* win9x version page (ALL versions !)
63 * can be found at www.mdgx.com/ver.htm */
64 static const RTL_OSVERSIONINFOEXW VersionData[NB_WINDOWS_VERSIONS] =
65 {
66 /* WIN20 FIXME: verify values */
67 {
68 sizeof(RTL_OSVERSIONINFOEXW), 2, 0, 0, VER_PLATFORM_WIN32s,
69 {'W','i','n','3','2','s',' ','1','.','3',0},
70 0, 0, 0, 0, 0
71 },
72 /* WIN30 FIXME: verify values */
73 {
74 sizeof(RTL_OSVERSIONINFOEXW), 3, 0, 0, VER_PLATFORM_WIN32s,
75 {'W','i','n','3','2','s',' ','1','.','3',0},
76 0, 0, 0, 0, 0
77 },
78 /* WIN31 */
79 {
80 sizeof(RTL_OSVERSIONINFOEXW), 3, 10, 0, VER_PLATFORM_WIN32s,
81 {'W','i','n','3','2','s',' ','1','.','3',0},
82 0, 0, 0, 0, 0
83 },
84 /* WIN95 */
85 {
86 /* Win95: 4, 0, 0x40003B6, ""
87 * Win95sp1: 4, 0, 0x40003B6, " A " (according to doc)
88 * Win95osr2: 4, 0, 0x4000457, " B " (according to doc)
89 * Win95osr2.1: 4, 3, 0x40304BC, " B " (according to doc)
90 * Win95osr2.5: 4, 3, 0x40304BE, " C " (according to doc)
91 * Win95a/b can be discerned via regkey SubVersionNumber
92 */
93 sizeof(RTL_OSVERSIONINFOEXW), 4, 0, 0x40003B6, VER_PLATFORM_WIN32_WINDOWS,
94 {0},
95 0, 0, 0, 0, 0
96 },
97 /* WIN98 (second edition) */
98 {
99 /* Win98: 4, 10, 0x40A07CE, " " 4.10.1998
100 * Win98SE: 4, 10, 0x40A08AE, " A " 4.10.2222
101 */
102 sizeof(RTL_OSVERSIONINFOEXW), 4, 10, 0x40A08AE, VER_PLATFORM_WIN32_WINDOWS,
103 {' ','A',' ',0},
104 0, 0, 0, 0, 0
105 },
106 /* WINME */
107 {
108 sizeof(RTL_OSVERSIONINFOEXW), 4, 90, 0x45A0BB8, VER_PLATFORM_WIN32_WINDOWS,
109 {' ',0},
110 0, 0, 0, 0, 0
111 },
112 /* NT351 */
113 {
114 sizeof(RTL_OSVERSIONINFOEXW), 3, 51, 0x421, VER_PLATFORM_WIN32_NT,
115 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
116 0, 0, 0, 0, 0
117 },
118 /* NT40 */
119 {
120 sizeof(RTL_OSVERSIONINFOEXW), 4, 0, 0x565, VER_PLATFORM_WIN32_NT,
121 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','6','a',0},
122 6, 0, 0, VER_NT_WORKSTATION, 0
123 },
124 /* NT2K */
125 {
126 sizeof(RTL_OSVERSIONINFOEXW), 5, 0, 0x893, VER_PLATFORM_WIN32_NT,
127 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','4',0},
128 4, 0, 0, VER_NT_WORKSTATION, 30 /* FIXME: Great, a reserved field with a value! */
129 },
130 /* WINXP */
131 {
132 sizeof(RTL_OSVERSIONINFOEXW), 5, 1, 0xA28, VER_PLATFORM_WIN32_NT,
133 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0},
134 3, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 30 /* FIXME: Great, a reserved field with a value! */
135 },
136 /* WIN2K3 */
137 {
138 sizeof(RTL_OSVERSIONINFOEXW), 5, 2, 0xECE, VER_PLATFORM_WIN32_NT,
139 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
140 2, 0, VER_SUITE_SINGLEUSERTS, VER_NT_SERVER, 0
141 },
142 /* WINVISTA */
143 {
144 sizeof(RTL_OSVERSIONINFOEXW), 6, 0, 0x1772, VER_PLATFORM_WIN32_NT,
145 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','2',0},
146 2, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0
147 },
148 /* WIN2K8 */
149 {
150 sizeof(RTL_OSVERSIONINFOEXW), 6, 0, 0x1771, VER_PLATFORM_WIN32_NT,
151 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
152 0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_SERVER, 0
153 },
154 /* WIN7 */
155 {
156 sizeof(RTL_OSVERSIONINFOEXW), 6, 1, 0x1DB1, VER_PLATFORM_WIN32_NT,
157 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
158 1, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0
159 },
160 /* WIN2K8 */
161 {
162 sizeof(RTL_OSVERSIONINFOEXW), 6, 1, 0x1DB1, VER_PLATFORM_WIN32_NT,
163 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','1',0},
164 1, 0, VER_SUITE_SINGLEUSERTS, VER_NT_SERVER, 0
165 },
166 
167 };
168 
169 static const char * const WinVersionNames[NB_WINDOWS_VERSIONS] =
170 { /* no spaces in here ! */
171 "win20", /* WIN20 */
172 "win30", /* WIN30 */
173 "win31", /* WIN31 */
174 "win95", /* WIN95 */
175 "win98", /* WIN98 */
176 "winme", /* WINME */
177 "nt351", /* NT351 */
178 "nt40", /* NT40 */
179 "win2000,win2k,nt2k,nt2000", /* NT2K */
180 "winxp", /* WINXP */
181 "win2003,win2k3", /* WIN2K3 */
182 "vista,winvista", /* WINVISTA*/
183 "win2008,win2k8", /* WIN2K8 */
184 "win2008r2,win2k8r2", /* WIN2K8R2 */
185 "win7", /* WIN7 */
186 };
187 
188 
189 /* initialized to null so that we crash if we try to retrieve the version too early at startup */
190 static const RTL_OSVERSIONINFOEXW *current_version;
191 
192 
193 /**********************************************************************
194 * get_nt_registry_version
195 *
196 * Fetch the version information from the NT-style registry keys.
197 */
198 static BOOL get_nt_registry_version( RTL_OSVERSIONINFOEXW *version )
199 {
200 static const WCHAR version_keyW[] = {'M','a','c','h','i','n','e','\\',
201 'S','o','f','t','w','a','r','e','\\',
202 'M','i','c','r','o','s','o','f','t','\\',
203 'W','i','n','d','o','w','s',' ','N','T','\\',
204 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
205 static const WCHAR service_pack_keyW[] = {'M','a','c','h','i','n','e','\\',
206 'S','y','s','t','e','m','\\',
207 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
208 'C','o','n','t','r','o','l','\\',
209 'W','i','n','d','o','w','s',0};
210 static const WCHAR product_keyW[] = {'M','a','c','h','i','n','e','\\',
211 'S','y','s','t','e','m','\\',
212 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
213 'C','o','n','t','r','o','l','\\',
214 'P','r','o','d','u','c','t','O','p','t','i','o','n','s',0};
215 static const WCHAR CurrentBuildNumberW[] = {'C','u','r','r','e','n','t','B','u','i','l','d','N','u','m','b','e','r',0};
216 static const WCHAR CSDVersionW[] = {'C','S','D','V','e','r','s','i','o','n',0};
217 static const WCHAR CurrentVersionW[] = {'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
218 static const WCHAR ProductTypeW[] = {'P','r','o','d','u','c','t','T','y','p','e',0};
219 static const WCHAR WinNTW[] = {'W','i','n','N','T',0};
220 static const WCHAR ServerNTW[] = {'S','e','r','v','e','r','N','T',0};
221 static const WCHAR LanmanNTW[] = {'L','a','n','m','a','n','N','T',0};
222 
223 OBJECT_ATTRIBUTES attr;
224 UNICODE_STRING nameW, valueW;
225 HANDLE hkey, hkey2;
226 char tmp[64];
227 DWORD count;
228 BOOL ret = FALSE;
229 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
230 
231 attr.Length = sizeof(attr);
232 attr.RootDirectory = 0;
233 attr.ObjectName = &nameW;
234 attr.Attributes = 0;
235 attr.SecurityDescriptor = NULL;
236 attr.SecurityQualityOfService = NULL;
237 RtlInitUnicodeString( &nameW, version_keyW );
238 
239 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) return FALSE;
240 
241 memset( version, 0, sizeof(*version) );
242 
243 RtlInitUnicodeString( &valueW, CurrentVersionW );
244 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
245 {
246 WCHAR *p, *str = (WCHAR *)info->Data;
247 str[info->DataLength / sizeof(WCHAR)] = 0;
248 p = strchrW( str, '.' );
249 if (p)
250 {
251 *p++ = 0;
252 version->dwMinorVersion = atoiW( p );
253 }
254 version->dwMajorVersion = atoiW( str );
255 }
256 
257 if (version->dwMajorVersion) /* we got the main version, now fetch the other fields */
258 {
259 ret = TRUE;
260 version->dwPlatformId = VER_PLATFORM_WIN32_NT;
261 
262 /* get build number */
263 
264 RtlInitUnicodeString( &valueW, CurrentBuildNumberW );
265 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
266 {
267 WCHAR *str = (WCHAR *)info->Data;
268 str[info->DataLength / sizeof(WCHAR)] = 0;
269 version->dwBuildNumber = atoiW( str );
270 }
271 
272 /* get version description */
273 
274 RtlInitUnicodeString( &valueW, CSDVersionW );
275 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
276 {
277 DWORD len = min( info->DataLength, sizeof(version->szCSDVersion) - sizeof(WCHAR) );
278 memcpy( version->szCSDVersion, info->Data, len );
279 version->szCSDVersion[len / sizeof(WCHAR)] = 0;
280 }
281 
282 /* get service pack version */
283 
284 RtlInitUnicodeString( &nameW, service_pack_keyW );
285 if (!NtOpenKey( &hkey2, KEY_ALL_ACCESS, &attr ))
286 {
287 RtlInitUnicodeString( &valueW, CSDVersionW );
288 if (!NtQueryValueKey( hkey2, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
289 {
290 if (info->DataLength >= sizeof(DWORD))
291 {
292 DWORD dw = *(DWORD *)info->Data;
293 version->wServicePackMajor = LOWORD(dw) >> 8;
294 version->wServicePackMinor = LOWORD(dw) & 0xff;
295 }
296 }
297 NtClose( hkey2 );
298 }
299 
300 /* get product type */
301 
302 RtlInitUnicodeString( &nameW, product_keyW );
303 if (!NtOpenKey( &hkey2, KEY_ALL_ACCESS, &attr ))
304 {
305 RtlInitUnicodeString( &valueW, ProductTypeW );
306 if (!NtQueryValueKey( hkey2, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
307 {
308 WCHAR *str = (WCHAR *)info->Data;
309 str[info->DataLength / sizeof(WCHAR)] = 0;
310 if (!strcmpiW( str, WinNTW )) version->wProductType = VER_NT_WORKSTATION;
311 else if (!strcmpiW( str, LanmanNTW )) version->wProductType = VER_NT_DOMAIN_CONTROLLER;
312 else if (!strcmpiW( str, ServerNTW )) version->wProductType = VER_NT_SERVER;
313 }
314 NtClose( hkey2 );
315 }
316 
317 /* FIXME: get wSuiteMask */
318 }
319 
320 NtClose( hkey );
321 return ret;
322 }
323 
324 
325 /**********************************************************************
326 * get_win9x_registry_version
327 *
328 * Fetch the version information from the Win9x-style registry keys.
329 */
330 static BOOL get_win9x_registry_version( RTL_OSVERSIONINFOEXW *version )
331 {
332 static const WCHAR version_keyW[] = {'M','a','c','h','i','n','e','\\',
333 'S','o','f','t','w','a','r','e','\\',
334 'M','i','c','r','o','s','o','f','t','\\',
335 'W','i','n','d','o','w','s','\\',
336 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0};
337 static const WCHAR VersionNumberW[] = {'V','e','r','s','i','o','n','N','u','m','b','e','r',0};
338 static const WCHAR SubVersionNumberW[] = {'S','u','b','V','e','r','s','i','o','n','N','u','m','b','e','r',0};
339 
340 OBJECT_ATTRIBUTES attr;
341 UNICODE_STRING nameW, valueW;
342 HANDLE hkey;
343 char tmp[64];
344 DWORD count;
345 BOOL ret = FALSE;
346 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
347 
348 attr.Length = sizeof(attr);
349 attr.RootDirectory = 0;
350 attr.ObjectName = &nameW;
351 attr.Attributes = 0;
352 attr.SecurityDescriptor = NULL;
353 attr.SecurityQualityOfService = NULL;
354 RtlInitUnicodeString( &nameW, version_keyW );
355 
356 if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) return FALSE;
357 
358 memset( version, 0, sizeof(*version) );
359 
360 RtlInitUnicodeString( &valueW, VersionNumberW );
361 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
362 {
363 WCHAR *p, *str = (WCHAR *)info->Data;
364 str[info->DataLength / sizeof(WCHAR)] = 0;
365 p = strchrW( str, '.' );
366 if (p) *p++ = 0;
367 version->dwMajorVersion = atoiW( str );
368 if (p)
369 {
370 str = p;
371 p = strchrW( str, '.' );
372 if (p)
373 {
374 *p++ = 0;
375 version->dwBuildNumber = atoiW( p );
376 }
377 version->dwMinorVersion = atoiW( str );
378 }
379 /* build number contains version too on Win9x */
380 version->dwBuildNumber |= MAKEWORD( version->dwMinorVersion, version->dwMajorVersion ) << 16;
381 }
382 
383 if (version->dwMajorVersion) /* we got the main version, now fetch the other fields */
384 {
385 ret = TRUE;
386 version->dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
387 
388 RtlInitUnicodeString( &valueW, SubVersionNumberW );
389 if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp)-1, &count ))
390 {
391 DWORD len = min( info->DataLength, sizeof(version->szCSDVersion) - sizeof(WCHAR) );
392 memcpy( version->szCSDVersion, info->Data, len );
393 version->szCSDVersion[len / sizeof(WCHAR)] = 0;
394 }
395 }
396 
397 NtClose( hkey );
398 return ret;
399 }
400 
401 
402 /**********************************************************************
403 * parse_win_version
404 *
405 * Parse the contents of the Version key.
406 */
407 static BOOL parse_win_version( HANDLE hkey )
408 {
409 static const WCHAR VersionW[] = {'V','e','r','s','i','o','n',0};
410 
411 UNICODE_STRING valueW;
412 char tmp[64], buffer[50];
413 KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)tmp;
414 DWORD count, len;
415 int i;
416 
417 RtlInitUnicodeString( &valueW, VersionW );
418 if (NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation, tmp, sizeof(tmp), &count ))
419 return FALSE;
420 
421 RtlUnicodeToMultiByteN( buffer, sizeof(buffer)-1, &len, (WCHAR *)info->Data, info->DataLength );
422 buffer[len] = 0;
423 
424 for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
425 {
426 const char *p, *pCurr = WinVersionNames[i];
427 /* iterate through all winver aliases separated by comma */
428 do {
429 p = strchr(pCurr, ',');
430 len = p ? p - pCurr : strlen(pCurr);
431 if ( (!strncmp( pCurr, buffer, len )) && (buffer[len] == 0) )
432 {
433 current_version = &VersionData[i];
434 TRACE( "got win version %s\n", WinVersionNames[i] );
435 return TRUE;
436 }
437 pCurr = p+1;
438 } while (p);
439 }
440 
441 MESSAGE("Invalid Windows version value '%s' specified in config file.\n", buffer );
442 MESSAGE("Valid versions are:" );
443 for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
444 {
445 /* only list the first, "official" alias in case of aliases */
446 const char *pCurr = WinVersionNames[i];
447 const char *p = strchr(pCurr, ',');
448 len = (p) ? p - pCurr : strlen(pCurr);
449 
450 MESSAGE(" '%.*s'%c", (int)len, pCurr, (i == NB_WINDOWS_VERSIONS - 1) ? '\n' : ',' );
451 }
452 return FALSE;
453 }
454 
455 
456 /**********************************************************************
457 * version_init
458 */
459 void version_init( const WCHAR *appname )
460 {
461 static const WCHAR configW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
462 static const WCHAR appdefaultsW[] = {'A','p','p','D','e','f','a','u','l','t','s','\\',0};
463 
464 OBJECT_ATTRIBUTES attr;
465 UNICODE_STRING nameW;
466 HANDLE root, hkey, config_key;
467 BOOL got_win_ver = FALSE;
468 
469 current_version = &VersionData[WINXP]; /* default if nothing else is specified */
470 
471 RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
472 attr.Length = sizeof(attr);
473 attr.RootDirectory = root;
474 attr.ObjectName = &nameW;
475 attr.Attributes = 0;
476 attr.SecurityDescriptor = NULL;
477 attr.SecurityQualityOfService = NULL;
478 RtlInitUnicodeString( &nameW, configW );
479 
480 /* @@ Wine registry key: HKCU\Software\Wine */
481 if (NtOpenKey( &config_key, KEY_ALL_ACCESS, &attr )) config_key = 0;
482 NtClose( root );
483 if (!config_key) goto done;
484 
485 /* open AppDefaults\\appname key */
486 if (appname && *appname)
487 {
488 const WCHAR *p;
489 WCHAR appversion[MAX_PATH+20];
490 
491 if ((p = strrchrW( appname, '/' ))) appname = p + 1;
492 if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
493 
494 strcpyW( appversion, appdefaultsW );
495 strcatW( appversion, appname );
496 RtlInitUnicodeString( &nameW, appversion );
497 attr.RootDirectory = config_key;
498 
499 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe */
500 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
501 {
502 TRACE( "getting version from %s\n", debugstr_w(appversion) );
503 got_win_ver = parse_win_version( hkey );
504 NtClose( hkey );
505 }
506 }
507 
508 if (!got_win_ver)
509 {
510 TRACE( "getting default version\n" );
511 got_win_ver = parse_win_version( config_key );
512 }
513 NtClose( config_key );
514 
515 done:
516 if (!got_win_ver)
517 {
518 static RTL_OSVERSIONINFOEXW registry_version;
519 
520 TRACE( "getting registry version\n" );
521 if (get_nt_registry_version( &registry_version ) ||
522 get_win9x_registry_version( &registry_version ))
523 current_version = &registry_version;
524 }
525 
526 
527 NtCurrentTeb()->Peb->OSMajorVersion = current_version->dwMajorVersion;
528 NtCurrentTeb()->Peb->OSMinorVersion = current_version->dwMinorVersion;
529 NtCurrentTeb()->Peb->OSBuildNumber = current_version->dwBuildNumber;
530 NtCurrentTeb()->Peb->OSPlatformId = current_version->dwPlatformId;
531 
532 user_shared_data->NtProductType = current_version->wProductType;
533 user_shared_data->ProductTypeIsValid = TRUE;
534 user_shared_data->MajorNtVersion = current_version->dwMajorVersion;
535 user_shared_data->MinorNtVersion = current_version->dwMinorVersion;
536 user_shared_data->MinorNtVersion = current_version->dwMinorVersion;
537 user_shared_data->SuiteMask = current_version->wSuiteMask;
538 
539 TRACE( "got %d.%d platform %d build %x name %s service pack %d.%d product %d\n",
540 current_version->dwMajorVersion, current_version->dwMinorVersion,
541 current_version->dwPlatformId, current_version->dwBuildNumber,
542 debugstr_w(current_version->szCSDVersion),
543 current_version->wServicePackMajor, current_version->wServicePackMinor,
544 current_version->wProductType );
545 }
546 
547 /***********************************************************************
548 * GetProductInfo (NTDLL.@)
549 *
550 * Gives info about the current Windows product type, in a format compatible
551 * with the given Windows version
552 *
553 * Returns TRUE if the input is valid, FALSE otherwise
554 */
555 BOOLEAN WINAPI RtlGetProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion,
556 DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType)
557 {
558 FIXME("(%d,%d,%d,%d,%p): stub\n", dwOSMajorVersion, dwOSMinorVersion,
559 dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType);
560 
561 *pdwReturnedProductType = PRODUCT_ULTIMATE_N;
562 
563 return TRUE;
564 }
565 
566 /***********************************************************************
567 * RtlGetVersion (NTDLL.@)
568 */
569 NTSTATUS WINAPI RtlGetVersion( RTL_OSVERSIONINFOEXW *info )
570 {
571 info->dwMajorVersion = current_version->dwMajorVersion;
572 info->dwMinorVersion = current_version->dwMinorVersion;
573 info->dwBuildNumber = current_version->dwBuildNumber;
574 info->dwPlatformId = current_version->dwPlatformId;
575 strcpyW( info->szCSDVersion, current_version->szCSDVersion );
576 if(info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
577 {
578 info->wServicePackMajor = current_version->wServicePackMajor;
579 info->wServicePackMinor = current_version->wServicePackMinor;
580 info->wSuiteMask = current_version->wSuiteMask;
581 info->wProductType = current_version->wProductType;
582 }
583 return STATUS_SUCCESS;
584 }
585 
586 
587 /******************************************************************************
588 * RtlGetNtVersionNumbers (NTDLL.@)
589 *
590 * Get the version numbers of the run time library.
591 *
592 * PARAMS
593 * major [O] Destination for the Major version
594 * minor [O] Destination for the Minor version
595 * build [O] Destination for the Build version
596 *
597 * RETURNS
598 * Nothing.
599 *
600 * NOTES
601 * Introduced in Windows XP (NT5.1)
602 */
603 void WINAPI RtlGetNtVersionNumbers( LPDWORD major, LPDWORD minor, LPDWORD build )
604 {
605 if (major) *major = current_version->dwMajorVersion;
606 if (minor) *minor = current_version->dwMinorVersion;
607 /* FIXME: Does anybody know the real formula? */
608 if (build) *build = (0xF0000000 | current_version->dwBuildNumber);
609 }
610 
611 
612 /******************************************************************************
613 * RtlGetNtProductType (NTDLL.@)
614 */
615 BOOLEAN WINAPI RtlGetNtProductType( LPDWORD type )
616 {
617 if (type) *type = current_version->wProductType;
618 return TRUE;
619 }
620 
621 
622 static inline NTSTATUS version_compare_values(ULONG left, ULONG right, UCHAR condition)
623 {
624 switch (condition) {
625 case VER_EQUAL:
626 if (left != right) return STATUS_REVISION_MISMATCH;
627 break;
628 case VER_GREATER:
629 if (left <= right) return STATUS_REVISION_MISMATCH;
630 break;
631 case VER_GREATER_EQUAL:
632 if (left < right) return STATUS_REVISION_MISMATCH;
633 break;
634 case VER_LESS:
635 if (left >= right) return STATUS_REVISION_MISMATCH;
636 break;
637 case VER_LESS_EQUAL:
638 if (left > right) return STATUS_REVISION_MISMATCH;
639 break;
640 default:
641 return STATUS_REVISION_MISMATCH;
642 }
643 return STATUS_SUCCESS;
644 }
645 
646 /******************************************************************************
647 * RtlVerifyVersionInfo (NTDLL.@)
648 */
649 NTSTATUS WINAPI RtlVerifyVersionInfo( const RTL_OSVERSIONINFOEXW *info,
650 DWORD dwTypeMask, DWORDLONG dwlConditionMask )
651 {
652 RTL_OSVERSIONINFOEXW ver;
653 NTSTATUS status;
654 
655 TRACE("(%p,0x%x,0x%s)\n", info, dwTypeMask, wine_dbgstr_longlong(dwlConditionMask));
656 
657 ver.dwOSVersionInfoSize = sizeof(ver);
658 if ((status = RtlGetVersion( &ver )) != STATUS_SUCCESS) return status;
659 
660 if(!(dwTypeMask && dwlConditionMask)) return STATUS_INVALID_PARAMETER;
661 
662 if(dwTypeMask & VER_PRODUCT_TYPE)
663 {
664 status = version_compare_values(ver.wProductType, info->wProductType, dwlConditionMask >> 7*3 & 0x07);
665 if (status != STATUS_SUCCESS)
666 return status;
667 }
668 if(dwTypeMask & VER_SUITENAME)
669 switch(dwlConditionMask >> 6*3 & 0x07)
670 {
671 case VER_AND:
672 if((info->wSuiteMask & ver.wSuiteMask) != info->wSuiteMask)
673 return STATUS_REVISION_MISMATCH;
674 break;
675 case VER_OR:
676 if(!(info->wSuiteMask & ver.wSuiteMask) && info->wSuiteMask)
677 return STATUS_REVISION_MISMATCH;
678 break;
679 default:
680 return STATUS_INVALID_PARAMETER;
681 }
682 if(dwTypeMask & VER_PLATFORMID)
683 {
684 status = version_compare_values(ver.dwPlatformId, info->dwPlatformId, dwlConditionMask >> 3*3 & 0x07);
685 if (status != STATUS_SUCCESS)
686 return status;
687 }
688 if(dwTypeMask & VER_BUILDNUMBER)
689 {
690 status = version_compare_values(ver.dwBuildNumber, info->dwBuildNumber, dwlConditionMask >> 2*3 & 0x07);
691 if (status != STATUS_SUCCESS)
692 return status;
693 }
694 
695 if(dwTypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
696 {
697 unsigned char condition = 0;
698 BOOLEAN do_next_check = TRUE;
699 
700 if(dwTypeMask & VER_MAJORVERSION)
701 condition = dwlConditionMask >> 1*3 & 0x07;
702 else if(dwTypeMask & VER_MINORVERSION)
703 condition = dwlConditionMask >> 0*3 & 0x07;
704 else if(dwTypeMask & VER_SERVICEPACKMAJOR)
705 condition = dwlConditionMask >> 5*3 & 0x07;
706 else if(dwTypeMask & VER_SERVICEPACKMINOR)
707 condition = dwlConditionMask >> 4*3 & 0x07;
708 
709 if(dwTypeMask & VER_MAJORVERSION)
710 {
711 status = version_compare_values(ver.dwMajorVersion, info->dwMajorVersion, condition);
712 do_next_check = (ver.dwMajorVersion == info->dwMajorVersion) &&
713 ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
714 }
715 if((dwTypeMask & VER_MINORVERSION) && do_next_check)
716 {
717 status = version_compare_values(ver.dwMinorVersion, info->dwMinorVersion, condition);
718 do_next_check = (ver.dwMinorVersion == info->dwMinorVersion) &&
719 ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
720 }
721 if((dwTypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
722 {
723 status = version_compare_values(ver.wServicePackMajor, info->wServicePackMajor, condition);
724 do_next_check = (ver.wServicePackMajor == info->wServicePackMajor) &&
725 ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
726 }
727 if((dwTypeMask & VER_SERVICEPACKMINOR) && do_next_check)
728 {
729 status = version_compare_values(ver.wServicePackMinor, info->wServicePackMinor, condition);
730 }
731 
732 if (status != STATUS_SUCCESS)
733 return status;
734 }
735 
736 return STATUS_SUCCESS;
737 }
Wine development tree
RSS Atom

abraço

Link para o comentário
Compartilhar em outros sites

  • 0

essas informações tambem vão ajudar

{ "win7", "Windows 7", 6, 1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "WinNT"}

{ "win2008", "Windows 2008", 6, 0, 0x1771,VER_PLATFORM_WIN32_NT, "Service Pack 1", 0, 0, "ServerNT"}

{ "vista", "Windows Vista", 6, 0, 0x1772,VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "WinNT"}

{ "win2003", "Windows 2003", 5, 2, 0xECE, VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "ServerNT"}

{ "winxp", "Windows XP", 5, 1, 0xA28, VER_PLATFORM_WIN32_NT, "Service Pack 3", 3, 0, "WinNT"}

{ "win2k", "Windows 2000", 5, 0, 0x893, VER_PLATFORM_WIN32_NT, "Service Pack 4", 4, 0, "WinNT"}

{ "winme", "Windows ME", 4, 90, 0xBB8, VER_PLATFORM_WIN32_WINDOWS, " ", 0, 0, ""}

{ "win98", "Windows 98", 4, 10, 0x8AE, VER_PLATFORM_WIN32_WINDOWS, " A ", 0, 0, ""}

{ "win95", "Windows 95", 4, 0, 0x3B6, VER_PLATFORM_WIN32_WINDOWS, "", 0, 0, ""}

{ "nt40", "Windows NT 4.0", 4, 0, 0x565, VER_PLATFORM_WIN32_NT, "Service Pack 6a", 6, 0, "WinNT"}

{ "nt351", "Windows NT 3.5", 3, 51, 0x421, VER_PLATFORM_WIN32_NT, "Service Pack 2", 0, 0, "WinNT"}

{ "win31", "Windows 3.1", 2, 10, 0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}

{ "win30", "Windows 3.0", 3, 0, 0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}

{ "win20", "Windows 2.0", 2, 0, 0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}

{ "win2008r2", "Windows 2008 R2", 6, 1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "ServerNT"}

{ "win7", "Windows 7", 6, 1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "WinNT"}

{ "win2008", "Windows 2008", 6, 0, 0x1771,VER_PLATFORM_WIN32_NT, "Service Pack 1", 0, 0, "ServerNT"}

{ "vista", "Windows Vista", 6, 0, 0x1772,VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "WinNT"}

{ "win2003", "Windows 2003", 5, 2, 0xECE, VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "ServerNT"}

{ "winxp", "Windows XP", 5, 1, 0xA28, VER_PLATFORM_WIN32_NT, "Service Pack 3", 3, 0, "WinNT"}

{ "win2k", "Windows 2000", 5, 0, 0x893, VER_PLATFORM_WIN32_NT, "Service Pack 4", 4, 0, "WinNT"}

{ "winme", "Windows ME", 4, 90, 0xBB8, VER_PLATFORM_WIN32_WINDOWS, " ", 0, 0, ""}

{ "win98", "Windows 98", 4, 10, 0x8AE, VER_PLATFORM_WIN32_WINDOWS, " A ", 0, 0, ""}

{ "win95", "Windows 95", 4, 0, 0x3B6, VER_PLATFORM_WIN32_WINDOWS, "", 0, 0, ""}

{ "nt40", "Windows NT 4.0", 4, 0, 0x565, VER_PLATFORM_WIN32_NT, "Service Pack 6a", 6, 0, "WinNT"}

{ "nt351", "Windows NT 3.5", 3, 51, 0x421, VER_PLATFORM_WIN32_NT, "Service Pack 2", 0, 0, "WinNT"}

{ "win31", "Windows 3.1", 2, 10, 0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}

{ "win30", "Windows 3.0", 3, 0, 0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}

{ "win20", "Windows 2.0", 2, 0, 0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}

abraço

Link para o comentário
Compartilhar em outros sites

  • 0

Parte da resposta:

procedure TForm1.Button1Click(Sender: TObject);
var
  Temp, Platform , Version : String;
  osInfo : TOSVersionInfo;
begin

  osInfo.dwOSVersionInfoSize:=SizeOf(osInfo);
  GetVersionEx(osInfo);
  Version :=IntToStr(osInfo.dwMinorVersion);
  Temp:=IntToStr(osInfo.dwBuildNumber and $0ffff);
  Temp:=String(osInfo.szCSDVersion);
  if (Length(Temp) > 0) then
    if (Temp[1] <> ' ') then
      Temp:=' ' + Temp;
  Version:= Version + Temp;

  label2.caption := Version;

  case osInfo.dwPlatformId of
    VER_PLATFORM_WIN32s :
      Platform:='Win32s';
    VER_PLATFORM_WIN32_WINDOWS : begin
      if (osInfo.dwMinorVersion = 0) then
        Platform:='Windows 95'
      else if (osInfo.dwMinorVersion = 10) then
        Platform:='Windows 98'
      else
        Platform:='Windows Me';
    end;
    VER_PLATFORM_WIN32_NT :
      case osInfo.dwMajorVersion of
        3 : Platform:='Windows NT 3';
        4 : Platform:='Windows NT 4.0';
        5 : case osInfo.dwMinorVersion of
              0: Platform:='Windows 2000, Windows Vista ou Windows Server 2008';
              1: Platform:='Windows XP';
              2: Platform:='Windows Server 2003 R2, 2003 ou XP Professional X64 Edition';
            else
              Platform:='Windows Version +';
            end;
      end;
  end;


  label1.caption := Platform;
end;

OBS: com as informações que te passei voce consegue complementar o código

abraço

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...