Obtener version de Windows
Dentro de mi programa de VB, tengo necesidad de saber si estoy corriendo en Win95, Win98, Win2000, etc
Como le puedo hacer para saber en cual version windows estoy corriendo ?
Como le puedo hacer para saber en cual version windows estoy corriendo ?
Creo que tengo el codigo que buscas .. te mando un email porque es un codigo un poco largo.
Espero que te sirva.
Espero que te sirva.
Option Explicit
Private Declare Function GetVersionEx& Lib "Kernel32" Alias _
"GetVersionExA" (lpVersionInformation As OSVERSIONINFO) 'As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
dwRevision As Long
End Type
Private Sub Form_Load()
Dim info As OSVERSIONINFO
Dim MsgEnd As String
Dim junk
Dim osvi As OSVERSIONINFO
osvi.dwOSVersionInfoSize = 148
junk = GetVersionEx(osvi)
If junk <> 0 Then
Select Case osvi.dwPlatformId
Case VER_PLATFORM_WIN32s
MsgEnd = "Microsoft Win32s"
Case VER_PLATFORM_WIN32_WINDOWS
If ((osvi.dwMajorVersion > 4) Or ((osvi.dwMajorVersion = 4) And (osvi.dwMinorVersion > 0))) Then
If osvi.dwMinorVersion = 1 Then
MsgEnd = "Microsoft Windows 98 Segona Edició"
Else
MsgEnd = "Microsoft Windows 98"
End If
Else
MsgEnd = "Microsoft Windows 95"
End If
Case VER_PLATFORM_WIN32_NT
If osvi.dwMajorVersion <= 4 Then
MsgEnd = "Microsoft Windows NT"
ElseIf osvi.dwMajorVersion = 5 Then
If osvi.dwMinorVersion = 1 Then
MsgEnd = "Microsoft Windows XP"
Else
MsgEnd = "Microsoft Windows 2000"
End If
End If
End Select
End If
Label9.Caption = "Aquest programa s'està executant sobre el sistema operatiu:" & vbCrLf & MsgEnd & ". Plataforma: " & osvi.dwPlatformId & ". Versió: " & osvi.dwMajorVersion & "." & osvi.dwMinorVersion & "." & " Compilació: " & osvi.dwBuildNumber & ". " & osvi.szCSDVersion
Private Declare Function GetVersionEx& Lib "Kernel32" Alias _
"GetVersionExA" (lpVersionInformation As OSVERSIONINFO) 'As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
dwRevision As Long
End Type
Private Sub Form_Load()
Dim info As OSVERSIONINFO
Dim MsgEnd As String
Dim junk
Dim osvi As OSVERSIONINFO
osvi.dwOSVersionInfoSize = 148
junk = GetVersionEx(osvi)
If junk <> 0 Then
Select Case osvi.dwPlatformId
Case VER_PLATFORM_WIN32s
MsgEnd = "Microsoft Win32s"
Case VER_PLATFORM_WIN32_WINDOWS
If ((osvi.dwMajorVersion > 4) Or ((osvi.dwMajorVersion = 4) And (osvi.dwMinorVersion > 0))) Then
If osvi.dwMinorVersion = 1 Then
MsgEnd = "Microsoft Windows 98 Segona Edició"
Else
MsgEnd = "Microsoft Windows 98"
End If
Else
MsgEnd = "Microsoft Windows 95"
End If
Case VER_PLATFORM_WIN32_NT
If osvi.dwMajorVersion <= 4 Then
MsgEnd = "Microsoft Windows NT"
ElseIf osvi.dwMajorVersion = 5 Then
If osvi.dwMinorVersion = 1 Then
MsgEnd = "Microsoft Windows XP"
Else
MsgEnd = "Microsoft Windows 2000"
End If
End If
End Select
End If
Label9.Caption = "Aquest programa s'està executant sobre el sistema operatiu:" & vbCrLf & MsgEnd & ". Plataforma: " & osvi.dwPlatformId & ". Versió: " & osvi.dwMajorVersion & "." & osvi.dwMinorVersion & "." & " Compilació: " & osvi.dwBuildNumber & ". " & osvi.szCSDVersion
