Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: ElChapu en Abril 29, 2011, 10:48:21 pm
-
hola buenas noches,
tengo una duda con windows y quisas ustedes me puedan ayudar.
alguien sabe como saber si el windows de donde esta corriendo el programa esta en windows 7?
yo uso un code que me dice hasta el win xp
Public Function getVersion() As String
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
With osinfo
Select Case .dwPlatformID
Case 1
Select Case .dwMinorVersion
Case 0
getVersion = "Windows 95"
Case 10
getVersion = "Windows 98"
Case 90
getVersion = "Windows Mellinnium"
End Select
Case 2
Select Case .dwMajorVersion
Case 3
getVersion = "Windows NT 3.51"
Case 4
getVersion = "Windows NT 4.0"
Case 5
If .dwMinorVersion = 0 Then
getVersion = "Windows 2000"
Else
getVersion = "Windows XP"
End If
End Select
Case Else
getVersion = "Failed"
End Select
End With
End Function
supongo que a ese code le hace falta los datos del windows 7 ya que no lo tiene,
bueno mi duda es si alguien conoce code que me hace falta.
muchas gracias por el espacio para realizar mi pregunta
saludos
-
codigo sacado de Api Guide:
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Sub main()
Dim OSInfo As OSVERSIONINFO, PId As String
'KPD-Team 1998
'URL: http://www.allapi.net/
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
'Get the Windows version
Ret& = GetVersionEx(OSInfo)
Debug.Print "Win version:" + Str$(OSInfo.dwMajorVersion) + "." + LTrim(Str(OSInfo.dwMinorVersion) + "." + Trim(Str(OSInfo.dwBuildNumber)))
End Sub
despues podrias hacer un select case de [Str$(OSInfo.dwMajorVersion) + "." + LTrim(Str(OSInfo.dwMinorVersion)] para asber si estas en Vista o Win7....
-
muchas gracias