Ciao a tutti,avevo scritto precedentemente in un altro post ma giustamente i moderatori mi hanno invitato,come pensavo, a creare una nuova discussione per evitare pasticci!
Avevo postato questo codice:
Che richiamavo in una status bar così:codice:Private Declare Function GetVersionExA Lib "Kernel32" (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 Public Enum Enum_OperatingPlatform Platform_Windows_32 = 0 Platform_Windows_95_98_ME = 1 Platform_Windows_NT_2K_XP = 2 End Enum Public Enum Enum_OperatingSystem System_Windows_32 = 0 System_Windows_95 = 1 System_Windows_98 = 2 System_Windows_ME = 3 System_Windows_NT = 4 System_Windows_2K = 5 System_Windows_XP = 6 End Enum Public Function OperatingPlatform() As Enum_OperatingPlatform Dim lpVersionInformation As OSVERSIONINFO lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation) Call GetVersionExA(lpVersionInformation) OperatingPlatform = lpVersionInformation.dwPlatformId End Function Public Function OperatingSystem() As Enum_OperatingSystem Dim lpVersionInformation As OSVERSIONINFO lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation) Call GetVersionExA(lpVersionInformation) If (lpVersionInformation.dwPlatformId = Platform_Windows_32) Then OperatingSystem = System_Windows_32 ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 0) Then OperatingSystem = System_Windows_95 ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 10) Then OperatingSystem = System_Windows_98 ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 90) Then OperatingSystem = System_Windows_ME ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion < 5) Then OperatingSystem = System_Windows_NT ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion = 5) And (lpVersionInformation.dwMinorVersion = 0) Then OperatingSystem = System_Windows_2K ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion = 5) And (lpVersionInformation.dwMinorVersion = 1) Then OperatingSystem = System_Windows_XP End If End Function
Anche qui avevo apportato delle modifiche ma purtroppo senza successo.Ora mi chiedevo perchè?naturalmente non ho incluso le mie modifiche lasciando solo il codice originale in modo tale che qualcuno possa divertirsi a farlo funzionare!codice:Me.sb.Panels(3).Text = OperatingSystem
Mentre ora utilizzando questo funziona.
In questo modo funziona,gli ho fatto qualche modifica,che si può tranquillamente vedere in ogni punto in cui c'è scritto vista, così da renderlo aggiornato al nuovo sistema operativo.codice:'-----Dichiarare in un form con command button-------- Option Explicit Const VER_PLATFORM_WIN32_VISTA = 2 Const VER_PLATFORM_WIN32_XP = 3 Const VER_PLATFORM_WIN32_NT = 6 Const VER_PLATFORM_WIN32_WINDOWS = 1 Const VER_PLATFORM_WIN32s = 0 Private Sub Command1_Click() Dim OS As OSVERSIONINFO OS.dwOSVersionInfoSize = Len(OS) GetVersionEx OS If OS.dwMajorVersion < 4 Then MsgBox "Impossibile continuare! E' richiesto Win 9x o WinNt 4.x", vbInformation End Else Select Case OS.dwPlatformId Case VER_PLATFORM_WIN32_WINDOWS MsgBox "Windows 95" & Str(OS.dwMajorVersion) & " Build " & Str(OS.dwBuildNumber), vbInformation Case VER_PLATFORM_WIN32_NT MsgBox "Windows NT Versione" & Str(OS.dwMajorVersion) & " Build " & Str(OS.dwBuildNumber), vbInformation Case VER_PLATFORM_WIN32_XP MsgBox "Windows XP Versione" & Str(OS.dwMajorVersion) & " Build " & Str(OS.dwBuildNumber), vbInformation Case VER_PLATFORM_WIN32_VISTA MsgBox "Windows Vista Ultimate Versione" & Str(OS.dwMajorVersion) & " Build " & Str(OS.dwBuildNumber), vbInformation End Select End If End Sub '------Dichiarare in modulo.bas-------- Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type


Rispondi quotando