Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA: Abfragen der Betriebssystem / Windows Version

1,463 views
Skip to first unread message

Thomas Schulze

unread,
Apr 22, 2003, 3:38:36 AM4/22/03
to
Guten Morgen zusammen,

ich möchte mit in einem VBA Modul die Windows Version herausfinden
um Inkompatitbilitäten mit DLL Funktionen abzufangen ... ich suche sowas
wie "Application.Version" (als Bsp. für die Excel Versionsabfrage) ...

Danke für jeden Tipp & Gruss
Thomas Schulze


Reiner Wolff

unread,
Apr 22, 2003, 3:54:57 AM4/22/03
to
Moin Thomas,

> ich möchte mit in einem VBA Modul die Windows Version herausfinden
> um Inkompatitbilitäten mit DLL Funktionen abzufangen ... ich suche sowas
> wie "Application.Version" (als Bsp. für die Excel Versionsabfrage) ...

Zum einen kannst Du einige Systeminformationen mit der Environ-Funktion abfragen.

Sub test()
Dim i As Integer

For i = 1 To 26
Cells(i, 1) = Environ(i)
Next
End Sub

Die Prozedur listet Dir die Möglichkeiten einmal auf einem Tabellenblatt auf.

Sollte die Systeminformation zu ungenau sein, so ermittelt sich die genaue Windows-Version dann mit Hilfe von
http://www.activevb.de/tipps/vb6tipps/tipp0129.html
Das ist zwar eigentlich für VB geschrieben, sollte aber unter VBA ganz genauso funktionieren. Ich habe jedenfalls auf die Schnelle
keine VB-spezifischen Dinge drin gefunden.

Greetinx aus Kiel
Reiner

Thomas Schulze

unread,
Apr 22, 2003, 4:29:11 AM4/22/03
to
Hallo Reiner,

sieht schonmal gut aus ... No. 11 ergibt als "OS=Windows_NT".

Vielen Dank & Gruss
Thomas

"Reiner Wolff" <sp...@wolffsrudel.de> wrote in message
news:Oh$UIRKCDH...@TK2MSFTNGP10.phx.gbl...

Reiner Wolff

unread,
Apr 22, 2003, 4:52:48 AM4/22/03
to
Moin Thomas,

>
> sieht schonmal gut aus ... No. 11 ergibt als "OS=Windows_NT".

Kannst Du dann übrigens auch über
Environ("OS")
ermitteln, dann ist der Code etwas leichter lesbar.

Allerdings ist Windows_NT ja durchaus in unterschiedlichen Versionen unterwegs, die ggf. auch anders auf bestimmte Dinge
reagieren...

Greetinx aus Kiel
Reiner

Thomas Schulze

unread,
Apr 22, 2003, 5:30:11 AM4/22/03
to
Hallo Christian,

das ist perfekt ...

Vielen Dank für den Tipp & Gruss
Thomas

"Christian Freßdorf" <Don...@gmx.net> wrote in message
news:e84py98t...@zaphod-systems.de...
> Hallo Thomas,


>
> > ich möchte mit in einem VBA Modul die Windows Version herausfinden
> > um Inkompatitbilitäten mit DLL Funktionen abzufangen ... ich suche sowas
> > wie "Application.Version" (als Bsp. für die Excel Versionsabfrage) ...
>

> geht mittels API:
>
> 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
> '
> Sub SysInfo()
> Dim OSInfo As OSVERSIONINFO, PId As String
> Dim Ret&
> Dim msg As String
> 'KPD-Team 1998
> 'URL: http://www.allapi.net/
> 'KPD...@Allapi.net
> 'Set the graphical mode to persistent
> 'Set the structure size
> OSInfo.dwOSVersionInfoSize = Len(OSInfo)
> 'Get the Windows version
> Ret& = GetVersionEx(OSInfo)
> 'Chack for errors
> If Ret& = 0 Then MsgBox "Error Getting Version Information": Exit Sub
> 'Print the information to the form
> Select Case OSInfo.dwPlatformId
> Case 0
> PId = "Windows 32s "
> Case 1
> PId = "Windows 95/98"
> Case 2
> PId = "Windows NT/2000 "
> End Select
> msg = "OS: " + PId & vbCrLf
> msg = msg & "Win version:" + Str$(OSInfo.dwMajorVersion) & "." & _
> LTrim(Str(OSInfo.dwMinorVersion)) & vbCrLf
> msg = msg & "Build: " + Str(OSInfo.dwBuildNumber)
> MsgBox msg
> End Sub
>
>
> --
> Gruß Christian


0 new messages