如何判断本机安装的是服务器端的操作系统(如Win2000Server)还是客户端的操作系统呢(如Win2000Professional)。100分酬谢!在线等待

解决方案 »

  1.   

    获取操作系统信息
    http://vbnet.mvps.org/code/helpers/iswinversion.htm
      

  2.   

    GetVersionEx VB声明 
    Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByVal lpVersionInformation As OSVERSIONINFO) As Long 
    说明 
    在一个OSVERSIONINFO结构中载入与平台和操作系统有关的版本信息 
    返回值 
    Long,非零表示成功,零表示失败 
    参数表 
    参数 类型及说明 
    lpVersionInformation OSVERSIONINFO,用于装载版本信息的结构。在正式调用函数之前,必须先将这个结构的dwOSVersionInfoSize字段设为结构的大小(148) OSVERSIONINFO 类型定义 
    Type OSVERSIONINFO ' 148 Bytes
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128 
    End Type 
    说明 
    This structure contains operating system version information. This structure is used with the GetVersionEx function.
     
    字段表 
    字段 类型与说明 
    dwOSVersionInfoSize Long,Size of this data structure, currently at 148 bytes. This field must be set before calling the GetVersionEx function. 
    dwMajorVersion Long,Specifies the major and minor version number of the operating system. 
    dwMinorVersion 
    dwBuildNumber Long,Specifies the build number of the operating system. On Windows 95, build 1000 respresents OEM service release #2. 
    dwPlatformId Long,Specifies the platform supported by the operating system. May be one of the following:VER_PLATFORM_WIN32s: Win32s on Windows 3.1.VER_PLATFORM_WIN32_WINDOWS: Win32 on Windows 95.VER_PLATFORM_WIN32_NT: Windows NT. 
    szCSDVersion String,Contains additional information about the operating system 
      

  3.   

    http://vbnet.mvps.org/index.html?code/helpers/iswinversion.htm推荐
      

  4.   

    老大们,我不是想要操作系统的版本号,而是要判断本机安装的操作系统是服务器端(如win2000 Server)还是客户端(如win2000 Professional)
      

  5.   

    GetVersionEx 这个函数能得到操作系统的类型的。具体怎么用,我不太记得了
    ^@^
      

  6.   

    如果只是得到平台类型,很方便可以实现,可以用GetVersionEx注定获得也可以用VerifyVersionInfo去验证,不过我觉得用GEt比较省事,很容易就写出来,也很容易理解。
    Private Type OSVERSIONINFOEX
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128
        wSPMajor As Integer
        wSPMinor As Integer
        wSuiteMask As Integer
        bProductType As Byte
        bReserved As Byte
    End Type
    这个结构中的bProductType 就是你想要的数据,它有三中可能,msdn解释:
    VER_NT_WORKSTATION 
    The system is running Windows NT 4.0 Workstation, Windows 2000 Professional, Windows XP Home Edition, or Windows XP Professional. 
    值为1
    VER_NT_DOMAIN_CONTROLLER 
    The system is a domain controller. 
    值为2
    VER_NT_SERVER 
    The system is a server. 
    值为3
    知道这些你就可写代码实现了
    声明必要的api
    Private Type OSVERSIONINFOEX
        dwOSVersionInfoSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformId As Long
        szCSDVersion As String * 128
        wSPMajor As Integer
        wSPMinor As Integer
        wSuiteMask As Integer
        bProductType As Byte
        bReserved As Byte
    End Type
    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long
    Private Sub Form_Load()
        Dim lpVersionInfo As OSVERSIONINFOEX    lpVersionInfo.dwOSVersionInfoSize = Len(lpVersionInfo)
    ‘长度要提供给api,否则api不知道长度,没法传递会数据    ret& = GetVersionEx(lpVersionInfo)
        Select Case lpVersionInfo.bProductType
          Case 1
            Label1.Caption = "NT_WORKSTATION"
          Case 2
           Label1.Caption = "NT_DOMAIN_CONTROLLER"
          Case 3
           Label1.Caption = "NT_SERVER"
          Case Else
           Label1.Caption = ""
        End Select
       
    End Sub
      

  7.   

    用WMI,记得先工程-引用 Microsoft WMI Scripting V1.1 Library
    http://vbnet.mvps.org/index.html?code/wmi/wmoperatingsystem.htm
    以下是取当前系统的代码
    Option ExplicitPrivate Sub Command1_Click()
    Dim wmiObjSet As SWbemObjectSet
    Dim obj As SWbemObject
    Dim msg As String
    Dim dtb As String
    Dim d As String
    Dim t As String
    Dim bias As Long
    On Local Error Resume Next
    Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_OperatingSystem")
    For Each obj In wmiObjSet
    MsgBox "你当前使用的系统是" & obj.Caption
    Next
    End Sub