取得Computer Name, OS的版本

  • 来源: 互联网 作者: 若水   2008-03-17/16:57
  • Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128 ' Maintenance string for PSS usage
    End Type

    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
    (lpVersionInformation As OSVERSIONINFO) As Long
    Private Declare Function GetComputerName Lib "kernel32" Alias _
    "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Private Sub Command1_Click()
    Dim len5 As Long, aa As Long
    Dim cmprName As String
    Dim osver As OSVERSIONINFO

    '取得Computer Name
    cmprName = String(255, 0)
    len5 = 256
    aa = GetComputerName(cmprName, len5)
    cmprName = Left(cmprName, InStr(1, cmprName, Chr(0)) - 1)
    Debug.Print "Computer Name = "; cmprName

    '取得OS的版本
    osver.dwOSVersionInfoSize = Len(osver)
    aa = GetVersionEx(osver)
    Debug.Print "MajorVersion "; osver.dwMajorVersion
    Debug.Print "MinorVersion "; osver.dwMinorVersion
    Select Case osver.dwPlatformId
    Case 0
    Debug.Print "Window 3.1"
    Case 1
    Debug.Print "Win95"
    Case 2
    Debug.Print "WinNT"
    End Select
    End Sub


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多