大侠、姐们。帮帮忙!我用VB写了一个程序,想让它运行在指定的系统上面该如何去做呢?
例如让程序只运行在"Windows 2000 Profressional"上面,当程序开始运行的时候告诉用户说:“本系统只能运行在windows 2000 profressional"帮帮忙!

解决方案 »

  1.   

    通过系统判断~好像是一个API叫做GetVersion~
      

  2.   

    "GetVersion"是获得什么版本哦?是自己的程序还是系统的?能清楚一点吗?
    谢谢!
    呜呜~~~~~~~~~~~~
      

  3.   

    这里有我用过的一个模块,源代码如下:模块代码:Option ExplicitPrivate Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As LongPrivate Type OSVERSIONINFO
            dwOSVersionInfoSize As Long
            dwMajorVersion As Long
            dwMinorVersion As Long
            dwBuildNumber As Long
            dwPlatformId As Long
            szCSDVersion As String * 128
    End TypePublic Const OSVerInvalid As Integer = 0
    Public Const OSVerWin95 As Integer = 1
    Public Const OSVerWin98 As Integer = 2
    Public Const OSVerWinNT35 As Integer = 3
    Public Const OSVerWinNT4 As Integer = 4
    Public Const OSVerWin2000 As Integer = 5Public Function GetOSVersion() As Integer
        Dim osVersion As OSVERSIONINFO
        Dim iRet As Integer
        osVersion.dwOSVersionInfoSize = 148
        osVersion.szCSDVersion = Space$(128)
        iRet = GetVersionEx(osVersion)
        If iRet > 0 Then
            With osVersion
            Select Case .dwPlatformId
                Case 1  ' Win9x
                    If .dwMinorVersion = 0 Then
                        GetOSVersion = OSVerWin95
                    ElseIf .dwMinorVersion = 10 Then
                        GetOSVersion = OSVerWin98
                    Else
                        GetOSVersion = OSVerInvalid
                    End If
                Case 2  ' WinNT or 2000
                    If .dwMajorVersion = 3 Then
                        GetOSVersion = OSVerWinNT35
                    ElseIf .dwMajorVersion = 4 Then
                        GetOSVersion = OSVerWinNT4
                    ElseIf .dwMajorVersion = 5 Then
                        GetOSVersion = OSVerWin2000
                    Else
                        GetOSVersion = OSVerInvalid
                    End If
                Case Else
                    GetOSVersion = OSVerInvalid
            End Select
            End With
        Else
            GetOSVersion = OSVerInvalid
        End If
    End Function
    窗体示例代码:Private Sub Command1_Click()
        Dim iVer As Integer
        Dim strVer As String
        iVer = GetOSVersion()
        Select Case iVer
            Case OSVerWin95
                strVer = "Windows 95"
            Case OSVerWin98
                strVer = "Windows 98"
            Case OSVerWinNT35
                strVer = "Windows NT 3.51"
            Case OSVerWinNT4
                strVer = "Windows NT 4"
            Case OSVerWin2000
                strVer = "Windows 2000"
            Case OSVerInvalid
                strVer = "Invalid Version Info"
        End Select
        MsgBox "你的系统平台是: " & strVer
    End Sub