Código: Seleccionar todo

http://www.recursosvisualbasic.com.ar/htm/listado-api/102-determinar-version-windows.htm
Función por defecto:

Código: Seleccionar todo

Option Explicit
Private Type OSVERSIONINFOEX
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type
    
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long
  
Public Function version_Windows() As String
       
Dim T_Version As OSVERSIONINFOEX, Mayor  As Long, Menor As Long
Dim Pid As Long, ret As String
       
With T_Version
.dwOSVersionInfoSize = Len(T_Version)
GetVersionEx T_Version
Mayor = .dwMajorVersion
Menor = .dwMinorVersion
Pid = .dwPlatformId
End With
       
Select Case Mayor

Case 5
If Menor = 0 Then
ret = "Windows 2000"
ElseIf Menor = 1 Then
ret = "Windows XP"
End If
               
Case 4
If Pid = 2 Then
ret = "Windows NT 4.0"
Else
ret = IIf(Menor = 0, "Windows 95", "Windows 98")
End If
        
Case 3
If Pid = 2 Then
ret = "Windows NT 3.x"
Else
ret = "Windows 3.x "
End If
               
Case Else
ret = "-"
End Select
                       
version_Windows = ret
End Function
Modificación:

Código: Seleccionar todo

Case 6
If Menor = 0 Then
ret = "Windows Vista"
ElseIf Menor = 1 Then
ret = "Windows 7"
End If

Código: Seleccionar todo

Option Explicit
Private Type OSVERSIONINFOEX
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type
    
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long
  
Public Function version_Windows() As String
       
Dim T_Version As OSVERSIONINFOEX, Mayor  As Long, Menor As Long
Dim Pid As Long, ret As String
       
With T_Version
.dwOSVersionInfoSize = Len(T_Version)
GetVersionEx T_Version
Mayor = .dwMajorVersion
Menor = .dwMinorVersion
Pid = .dwPlatformId
End With
       
Select Case Mayor

Case 6
If Menor = 0 Then
ret = "Windows Vista"
ElseIf Menor = 1 Then
ret = "Windows 7"
End If

Case 5
If Menor = 0 Then
ret = "Windows 2000"
ElseIf Menor = 1 Then
ret = "Windows XP"
End If
               
Case 4
If Pid = 2 Then
ret = "Windows NT 4.0"
Else
ret = IIf(Menor = 0, "Windows 95", "Windows 98")
End If
        
Case 3
If Pid = 2 Then
ret = "Windows NT 3.x"
Else
ret = "Windows 3.x "
End If
               
Case Else
ret = "-"
End Select
                       
version_Windows = ret
End Function
Pueden continuar modificando:

Código: Seleccionar todo

http://es.wikipedia.org/wiki/Windows#Historial_de_lanzamientos
[Enlace externo eliminado para invitados]

Ahora ya detecta Windows Vista y Windows 7.

Saludos.
Muchas gracias.... funciona perfecto en mi 7.
Spyren Private Crypter-Binder [Autoit]
Crypter Online 0/35 (Terminado)
Responder

Volver a “Otros lenguajes”