Rajesh M
October 24th, 2001, 06:09 AM
From Visual Basic Code how can i know the underlying Operating System.
|
Click to See Complete Forum and Search --> : Operating System Rajesh M October 24th, 2001, 06:09 AM From Visual Basic Code how can i know the underlying Operating System. Clearcode October 24th, 2001, 06:31 AM You could use the EventVB.dll which is downloadable from http://www.merrioncomputing.com/Download/index.htm thus: option Explicit Dim withevents ApiLink as EventVB.APIFunctions private Sub Form_Load() set ApiLink = new EventVB.APIFunctions With ApiLink.System Select Case .WindowsOSVersion Case ver_Win_95 Debug.print "Windows 95" Case ver_Win_98 Debug.print "Windows 98" Case ver_Win_Me Debug.print "Windows me " Case ver_Win_NT351 Debug.print "Windows NT 3.51" Case ver_win_nt4 Debug.print "Windows NT 4 " Case ver_Win_Win2000 Debug.print "Windows 2000 " Case ver_win_Whistler Debug.print "Whistler (Beta) " End Select Debug.print "Build " & .WindowsOSBuild Debug.print .WindowsOSCSDVersion End With End Sub For me this returns: Windows NT 4 Build 1381 Service Pack 4 HTH, Duncan ------------------------------------------------- Ex. Datis: Duncan Jones Merrion Computing Ltd http://www.merrioncomputing.com Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included. Iouri October 24th, 2001, 07:12 AM 'form Private Sub Command1_Click() MsgBox GetOSVer End Sub 'module Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _ (lpVersionInformation As OSVERSIONINFOEX) As Long Private Type OSVERSIONINFOEX dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 wServicePackMajor As Integer wServicePackMinor As Integer wSuiteMask As Integer wProductType As Byte wReserved As Byte End Type 'used for platform id Const VER_PLATFORM_WIN32s = 0 'win 3.x Const VER_PLATFORM_WIN32_WINDOWS = 1 'win 9.x Const VER_PLATFORM_WIN32_NT = 2 'win nt,2000,XP 'used for product type Const VER_NT_WORKSTATION = 1 Const VER_NT_SERVER = 3 'used for suite mask Const VER_SUITE_DATACENTER = 128 Const VER_SUITE_ENTERPRISE = 2 Const VER_SUITE_PERSONAL = 512 Public Function GetOSVer() As String Dim osv As OSVERSIONINFOEX osv.dwOSVersionInfoSize = Len(osv) If GetVersionEx(osv) = 1 Then Select Case osv.dwPlatformId Case Is = VER_PLATFORM_WIN32s GetOSVer = "Windows 3.x" Case Is = VER_PLATFORM_WIN32_WINDOWS Select Case osv.dwMinorVersion Case Is = 0 If InStr(UCase(osv.szCSDVersion), "C") Then GetOSVer = "Windows 95 OSR2" Else GetOSVer = "Windows 95" End If Case Is = 10 If InStr(UCase(osv.szCSDVersion), "A") Then GetOSVer = "Windows 98 SE" Else GetOSVer = "Windows 98" End If Case Is = 90 GetOSVer = "Windows Me" End Select Case Is = VER_PLATFORM_WIN32_NT Select Case osv.dwMajorVersion Case Is = 3 Select Case osv.dwMinorVersion Case Is = 0 GetOSVer = "Windows NT 3" Case Is = 1 GetOSVer = "Windows NT 3.1" Case Is = 5 GetOSVer = "Windows NT 3.5" Case Is = 51 GetOSVer = "Windows NT 3.51" End Select Case Is = 4 GetOSVer = "Windows NT 4" Case Is = 5 Select Case osv.dwMinorVersion Case Is = 0 'win 2000 Select Case osv.wProductType Case Is = VER_NT_WORKSTATION GetOSVer = "Windows 2000 Professional" Case Is = VER_NT_SERVER Select Case osv.wSuiteMask Case Is = VER_SUITE_DATACENTER GetOSVer = "Windows 2000 DataCenter Server" Case Is = VER_SUITE_ENTERPRISE GetOSVer = "Windows 2000 Advanced Server" Case Else GetOSVer = "Windows 2000 Server" End Select End Select Case Is = 1 'win XP or win .NET server Select Case osv.wProductType Case Is = VER_NT_WORKSTATION 'win XP If osv.wSuiteMask = VER_SUITE_PERSONAL Then GetOSVer = "Windows XP Home Edition" Else GetOSVer = "Windows XP Professional" End If Case Else If osv.wSuiteMask = VER_SUITE_ENTERPRISE Then GetOSVer = "Windows .NET Enterprise Server" Else GetOSVer = "Windows .NET Server" End If End Select End Select End Select End Select End If End Function Iouri Boutchkine iouri@hotsheet.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |