VERSAO WINDOWS
Ola pessoal, gostaria de saber se existe a possibilidade de eu descobrir a versão do windows pelo VB sem usar Class Module, eu so quero diferenciar se o sistema é windows98 ou windows Xp
Coloque um CLASS MODULE , não é MODULE. (CLASS MODULE é diferente de MODULE com Name "SO")
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Private lngTotalMemory As Long
Private lngAvailableMemory As Long
Private strOSVersion As String
Private sngOSBuild As Single
Private strOSPlatform As String
Private lngProcessor As Long
Private Type MEMORYSTATUS
Length As Long
MemoryLoad As Long
TotalPhys As Long
AvailPhys As Long
TotalPageFile As Long
AvailPageFile As Long
TotalVirtual As Long
AvailVirtual As Long
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpOSInfo As OSVERINFO) As Boolean
Private Type OSVERINFO ' Operating System Version Information
OSVerInfoSize As Long
MajorVer As Long
MinorVer As Long
BuildNo As Long
PlatformId As Long
strReserved As String * 128
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" _
(lpSystemInfo As SYSTEM_INFO)
Private Type SYSTEM_INFO
OEMId As Long
PageSize As Long
MinimumApplicationAddress As Long
MaximumApplicationAddress As Long
ActiveProcessorMark As Long
NumberOfProcessors As Long
ProcessorType As Long
AllocationGranularity As Long
lngReserved As Long
End Type
Public Property Get TotalMemory() As Long
TotalMemory = lngTotalMemory
End Property
Public Property Get AvailableMemory() As Long
AvailableMemory = lngAvailableMemory
End Property
Public Property Get OSVersion() As String
OSVersion = strOSVersion
End Property
Public Property Get OSBuild() As Single
OSBuild = sngOSBuild
End Property
Public Property Get OSPlatform() As String
OSPlatform = strOSPlatform
End Property
Public Property Get Processor() As Long
Processor = lngProcessor
End Property
Private Sub Class_Initialize()
' Really all the work is done here
' It makes all the API calls
' Getting free memory
Dim MemStat As MEMORYSTATUS
MemStat.Length = Len(MemStat)
GlobalMemoryStatus MemStat
lngTotalMemory = Format(MemStat.TotalPhys, "Standard")
lngAvailableMemory = Format(MemStat.AvailPhys, "Standard")
' Getting version info
Dim OSInfo As OSVERINFO
OSInfo.OSVerInfoSize = Len(OSInfo)
If GetVersionEx(OSInfo) Then
strOSVersion = OSInfo.MajorVer & "." & OSInfo.MinorVer
sngOSBuild = OSInfo.BuildNo And &HFFFF&
If OSInfo.PlatformId = 0 Then
strOSPlatform = "Windows 95"
ElseIf OSInfo.PlatformId = 1 Then
strOSPlatform = "Windows 98"
Else
strOSPlatform = "Windows NT/2000"
End If
End If
' Getting system info
Dim SI As SYSTEM_INFO
GetSystemInfo SI
lngProcessor = SI.ProcessorType
End Sub
No form coloque
Private Sub Form_Load()
Dim SysInfo As SO
Set SysInfo = New SO
With SysInfo
Text1.Text = vbCrLf & " Memória total: " & .TotalMemory & vbCrLf & _
vbCrLf & " Versão do Sistema Operacional: " & .OSVersion & vbCrLf & _
vbCrLf & " Plataforma: " & .OSPlatform & vbCrLf & _
vbCrLf & " Processador: " & .Processor
End With
End Sub
finalize o topico.
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Private lngTotalMemory As Long
Private lngAvailableMemory As Long
Private strOSVersion As String
Private sngOSBuild As Single
Private strOSPlatform As String
Private lngProcessor As Long
Private Type MEMORYSTATUS
Length As Long
MemoryLoad As Long
TotalPhys As Long
AvailPhys As Long
TotalPageFile As Long
AvailPageFile As Long
TotalVirtual As Long
AvailVirtual As Long
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpOSInfo As OSVERINFO) As Boolean
Private Type OSVERINFO ' Operating System Version Information
OSVerInfoSize As Long
MajorVer As Long
MinorVer As Long
BuildNo As Long
PlatformId As Long
strReserved As String * 128
End Type
Private Declare Sub GetSystemInfo Lib "kernel32" _
(lpSystemInfo As SYSTEM_INFO)
Private Type SYSTEM_INFO
OEMId As Long
PageSize As Long
MinimumApplicationAddress As Long
MaximumApplicationAddress As Long
ActiveProcessorMark As Long
NumberOfProcessors As Long
ProcessorType As Long
AllocationGranularity As Long
lngReserved As Long
End Type
Public Property Get TotalMemory() As Long
TotalMemory = lngTotalMemory
End Property
Public Property Get AvailableMemory() As Long
AvailableMemory = lngAvailableMemory
End Property
Public Property Get OSVersion() As String
OSVersion = strOSVersion
End Property
Public Property Get OSBuild() As Single
OSBuild = sngOSBuild
End Property
Public Property Get OSPlatform() As String
OSPlatform = strOSPlatform
End Property
Public Property Get Processor() As Long
Processor = lngProcessor
End Property
Private Sub Class_Initialize()
' Really all the work is done here
' It makes all the API calls
' Getting free memory
Dim MemStat As MEMORYSTATUS
MemStat.Length = Len(MemStat)
GlobalMemoryStatus MemStat
lngTotalMemory = Format(MemStat.TotalPhys, "Standard")
lngAvailableMemory = Format(MemStat.AvailPhys, "Standard")
' Getting version info
Dim OSInfo As OSVERINFO
OSInfo.OSVerInfoSize = Len(OSInfo)
If GetVersionEx(OSInfo) Then
strOSVersion = OSInfo.MajorVer & "." & OSInfo.MinorVer
sngOSBuild = OSInfo.BuildNo And &HFFFF&
If OSInfo.PlatformId = 0 Then
strOSPlatform = "Windows 95"
ElseIf OSInfo.PlatformId = 1 Then
strOSPlatform = "Windows 98"
Else
strOSPlatform = "Windows NT/2000"
End If
End If
' Getting system info
Dim SI As SYSTEM_INFO
GetSystemInfo SI
lngProcessor = SI.ProcessorType
End Sub
No form coloque
Private Sub Form_Load()
Dim SysInfo As SO
Set SysInfo = New SO
With SysInfo
Text1.Text = vbCrLf & " Memória total: " & .TotalMemory & vbCrLf & _
vbCrLf & " Versão do Sistema Operacional: " & .OSVersion & vbCrLf & _
vbCrLf & " Plataforma: " & .OSPlatform & vbCrLf & _
vbCrLf & " Processador: " & .Processor
End With
End Sub
finalize o topico.
Formiguinha sei que você tentou ajudar mais eu perguntei sem usar Class module, se alguem souber, vlw galera
simplificando a dica da FORMIGUINHA:
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpOSInfo As OSVERINFO) As Boolean
Private Type OSVERINFO ' Operating System Version Information
OSVerInfoSize As Long
MajorVer As Long
MinorVer As Long
BuildNo As Long
PlatformId As Long
strReserved As String * 128
End Type
Private Sub Form_Load()
Dim OSInfo As OSVERINFO
OSInfo.OSVerInfoSize = Len(OSInfo)
If GetVersionEx(OSInfo) Then
strOSVersion = OSInfo.MajorVer & "." & OSInfo.MinorVer
sngOSBuild = OSInfo.BuildNo And &HFFFF&
If OSInfo.PlatformId = 0 Then
strOSPlatform = "Windows 95"
ElseIf OSInfo.PlatformId = 1 Then
strOSPlatform = "Windows 98"
Else
strOSPlatform = "Windows NT/2000"
End If
End If
MsgBox strOSPlatform
End Sub
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpOSInfo As OSVERINFO) As Boolean
Private Type OSVERINFO ' Operating System Version Information
OSVerInfoSize As Long
MajorVer As Long
MinorVer As Long
BuildNo As Long
PlatformId As Long
strReserved As String * 128
End Type
Private Sub Form_Load()
Dim OSInfo As OSVERINFO
OSInfo.OSVerInfoSize = Len(OSInfo)
If GetVersionEx(OSInfo) Then
strOSVersion = OSInfo.MajorVer & "." & OSInfo.MinorVer
sngOSBuild = OSInfo.BuildNo And &HFFFF&
If OSInfo.PlatformId = 0 Then
strOSPlatform = "Windows 95"
ElseIf OSInfo.PlatformId = 1 Then
strOSPlatform = "Windows 98"
Else
strOSPlatform = "Windows NT/2000"
End If
End If
MsgBox strOSPlatform
End Sub
aqui no site tem uma
http://www.vbmania.com.br/vbmforum.php?varMethod=Abrir&varID=43696&varSubPagina=1&varFiltro=filtro
aparentemente igual a do jean jedson, a unica diferença que vejo e quanto ao XP.
http://www.vbmania.com.br/vbmforum.php?varMethod=Abrir&varID=43696&varSubPagina=1&varFiltro=filtro
aparentemente igual a do jean jedson, a unica diferença que vejo e quanto ao XP.
apenas simplifiquei o código postado pela formiguinha
Tópico encerrado , respostas não são mais permitidas