VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 取得Computer Name, OS的版本
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:10317, 日期:2001-09-17
  
    取得Computer Name, OS的版本


 

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