Obtain the current system version number

Source: Internet
Author: User

Obtain the current system version number
 Unit Winverutils; {#===================================================== ========================================================== = # Name: winverutils. PAS # Author: Aleksander oven # created: 2007-02-25 # last change: 2007-02-25 # version: 1.0 # Description: All about the version of the Windows OS. reference: http://msdn2.microsoft.com/en-us/library/ms724451.aspx# warnings and/or special considerations: source code in this file is free for personal and other cial use. #===================================================== ==========================================================}  Interface  Type Twindowsversion = (examples, wvwindows95, examples, wvwindows98, wvwindows98se, wvwindowsme, examples, wvwindows2000, wvwindowsxp, wvwindowsxp SP2, templates, wvwindowsserver2003, wvwindowsvista, templates ); Function Getwindowsversion: twindowsversion; Function Getwindowsname: ansistring; Function Getwindowsversionstring: ansistring; Implementation  Uses Windows, sysutils; Type Tosversioninfoexa = Packed  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 ; Const Cwindowsversions: Array [Twindowsversion] Of Ansistring = ( 'Not cognized' ,'Windows 95' , 'Windows 95 OSR 2' , 'Windows 98' , 'Windows 98 Second version' , 'Windows Millenium' , 'Windows nt' , 'Windows NT 3.5' , 'Windows NT 4.0' , 'Windows 2000' , 'Windows XP' , 'Windows XP Service Pack 2' , 'Windows XP x64' , 'Windows Server 2003' , 'Windows Vista' , 'Windows server longhorn' ); Function Getversionexa (lpversioninformation: pointer): bool; Stdcall ; External Kernel32 name 'Getversionexa' ; Function Getwindowsversion: twindowsversion; Const Ver_nt_workstation = $ 01 ; VaR VI: tosversioninfoa; viex: tosversioninfoexa; Begin Result: = wvnotrecognized; vi . Dwosversioninfosize: = sizeof (tosversioninfoa ); If   Not Getversionexa (@ VI) Then Exit; Case VI . Dwplatformid Of Ver_platform_win32_windows: Begin          Case VI . Dwminorversion Of            0 : Begin                If (Vi . Szcsdversion [ 1 ] = 'B' ) Then Result: = wvwindows95osr2 Else Result: = wvwindows95; End ; 10 : Begin                If (Vi . Szcsdversion [ 1 ] = 'A' ) Then Result: = wvwindows98se Else Result: = wvwindows98; End ; 90 : Begin                If (Vi . Dwbuildnumber = $045a0bb8) Then Result: = wvwindowsme; End ; End ; End ; Ver_platform_win32_nt: Begin         Case VI . Dwmajorversion Of            3 : Result: = wvwindowsnt35; 4 : Result: = wvwindowsnt40; Else Viex . Dwosversioninfosize: = sizeof (tosversioninfoexa ); If   Not Getversionexa (@ viex) Then Viex . Dwosversioninfosize: = 0 ;Case VI . Dwmajorversion Of              5 : Begin                  Case VI . Dwminorversion Of                    0 : Result: = wvwindows2000; 1 : Begin                        If (Pos ( 'Service pack 2' , Ansistring (VI . Szcsdversion)>0 ) Then Result: = wvwindowssp2 SP2 Else Result: = wvwindowsxp; End ; 2 : Begin Result: = wvwindowsxp64; If (Viex . Dwosversioninfosize> 0 ) And (Viex . Wproducttype <> ver_nt_workstation) Then Result: = wvwindowsserver2003; End                  Else Result: = wvwindowsnt; End ; End ; 6 : Begin Result: = wvwindowsvista; If (Viex . Dwosversioninfosize> 0 )And (Viex . Wproducttype <> ver_nt_workstation) Then Result: = wvwindowsserverlonghorn; End ; End ; End ; End ; End ; End ; Function Getwindowsname: ansistring; Begin Result: = cwindowsversions [getwindowsversion]; End ; Function Getwindowsversionstring: ansistring; VaR VI: tosversioninfoa; Begin VI . Dwosversioninfosize: = sizeof (tosversioninfoa ); If Getversionexa (@ VI) Then      With VI Do Result: = trim (format ( '% D. % d build % d % s' , [Dwmajorversion, dwminorversion, dwbuildnumber, szcsdversion]) Else Result: = '' ; End ; End .

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.