Lm th? no ? xc ?nh phin b?n Windows 32-bit ang ?c s? d?ng

D?ch tiu ? D?ch tiu ?
ID c?a bi: 189249 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

M?t ?ng d?ng c th? c?n th?c hi?n cng vi?c m?t cch khc nhau ty thu?c vo h? i?u hnh ang ch?y trn my tnh. Bi vi?t ny cho th?y, b?i v d?, lm th? no ? phn bi?t gi?a Microsoft Windows 95, Microsoft Windows 98, Microsoft Window NT 3.51, Microsoft Windows NT 4.0, Microsoft Windows 2000 v Microsoft Windows XP.

Win32 GetVersionEx ch?c nng tr? v? thng tin m m?t chng tr?nh c th? s? d?ng ? xc ?nh h? i?u hnh. Trong s? nh?ng gi tr? ang l?n v cc con s? s?a ?i nh? v m?t n?n t?ng m? ?nh danh. V?i s? ra ?i c?a Windows 98, by gi? m?t m?t nh gi h?p l? hn tham gia ? xc ?nh Phin b?n no c?a Windows ang dng. B?ng li?t k d?i y cung c?p d? li?u c?n thi?t ? nh gi c?u trc OSVERSIONINFO dn c c?a cc GetVersionEx ch?c nng:
Thu g?n b?ng nyBung r?ng b?ng ny
Windows 95Windows 98Windows MeWindows NT 4.0Windows 2000Windows XP
PlatformID 1 1 1 2 2 2
Phin b?n chnh 4 4 4 4 5 5
Phin b?n nh? 0 10 90 0 0 1

THNG TIN THM

V d?-by-step

  1. B?t ?u m?t d? n tiu chu?n EXE m?i trong Visual Basic. Form1 ?c t?o ra theo m?c ?nh.
  2. T? cc D an tr?nh n, thm m?t Tiu chu?n phn h? cho d? n.
  3. Chn o?n m? sau vo Module1:
          Public Declare Function GetVersionExA Lib "kernel32" _
                   (lpVersionInformation As OSVERSIONINFO) As Integer
     
                Public Type OSVERSIONINFO
                   dwOSVersionInfoSize As Long
                   dwMajorVersion As Long
                   dwMinorVersion As Long
                   dwBuildNumber As Long
                   dwPlatformId As Long
                   szCSDVersion As String * 128
                End Type
     
                Public Function getVersion() As String
                   Dim osinfo As OSVERSIONINFO
                   Dim retvalue As Integer
     
                   osinfo.dwOSVersionInfoSize = 148
                   osinfo.szCSDVersion = Space$(128)
                   retvalue = GetVersionExA(osinfo)
     
                   With osinfo
                   Select Case .dwPlatformId
     
                    Case 1
                    
                        Select Case .dwMinorVersion
                            Case 0
                                getVersion = "Windows 95"
                            Case 10
                                getVersion = "Windows 98"
                            Case 90
                                getVersion = "Windows Millennium"
                        End Select
        
                    Case 2
                        Select Case .dwMajorVersion
                            Case 3
                                getVersion = "Windows NT 3.51"
                            Case 4
                                getVersion = "Windows NT 4.0"
                            Case 5
                                If .dwMinorVersion = 0 Then
                                    getVersion = "Windows 2000"
                                Else
                                    getVersion = "Windows XP"
                                End If
                        End Select
        
                    Case Else
                       getVersion = "Failed"
                End Select
     
                   End With
                End Function
    
    					
  4. Thm d?ng sau m? ? cc T?i s? ki?n c?a Form1:
    MsgBox GetVersion()
    					
  5. Ch?y cc d? n, v lu ? r?ng m?t h?p thng i?p s? hi?n th? cc phin b?n Windows chnh xc.

THAM KH?O

bit thm thng tin, bm vao s bai vit sau xem bai vit trong C s Kin thc Microsoft:
92936Lm th? no ? c ?c s? phin b?n Windows 3.1 trong VB v?i GetVersion

Thu?c tnh

ID c?a bi: 189249 - L?n xem xt sau cng: 20 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 4.0 Standard Edition
T? kha:
kbhowto kbmt KB189249 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:189249

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com