Betriebssystem-Informationen

Hier könnt Ihr gute, von Euch geschriebene Codes posten. Sie müssen auf jeden Fall funktionieren und sollten möglichst effizient, elegant und beispielhaft oder einfach nur cool sein.
Benutzeravatar
Helle
Beiträge: 566
Registriert: 11.11.2004 16:13
Wohnort: Magdeburg

Betriebssystem-Informationen

Beitrag von Helle »

Mitunter braucht man vom Betriebssystem mehr Informationen als "OSVersion" liefert, z.B. das installierte Service-Pack. Hier ein Grundgerüst, das je nach Bedarf erweitert werden kann:

Code: Alles auswählen

;Vorhandenes Windows-Betriebssystem und Zusatz-Informationen ermitteln
;Dieses Beispiel berücksichtigt nur die Win-NT-Versionen (also NT 4.0, 2000, XP, Vista, Server)
;Verwendet wird die API-Funktion GetVersionEx, die Daten werden in der Struktur OSVERSIONINFOEX gespeichert 
;- "Helle" Klaus Helbing, 12.04.2008, PB4.10 

;------------------------------------------------
;Aufbau von OSVERSIONINFOEX, ist (auch) PB-Struktur
;Structure OSVERSIONINFOEX
;  dwOSVersionInfoSize.l
;  dwMajorVersion.l
;  dwMinorVersion.l
;  dwBuildNumber.l
;  dwPlatformId.l
;  szCSDVersion.c[128]
;  wServicePackMajor.w
;  wServicePackMinor.w
;  wSuiteMask.w
;  wProductType.b
;  wReserved.b
;EndStructure
;------------------------------------------------

;--------------------------------------------------------------------------------------------------
;Erläuterungen zur Struktur
;MajorVersion:
;3 = Windows NT 3.51
;4 = Windows NT 4.0, Windows 95, Windows 98 oder Windows ME
;5 = Windows Server 2003 R2, Windows Server 2003, Windows XP oder Windows 2000
;6 = Windows Vista oder Windows Server 2008
;--------
;MinorVersion:
;0 = Windows Server 2008, Windows Vista oder Windows 2000
;1 = Windows XP
;2 = Windows Server 2003 R2, Windows Server 2003 oder Windows XP Professional x64 Edition
;--------
;BuildNumber (Auswahl):
; 528 = Windows NT 3.1
; 807 = Windows NT 3.5
; 950 = Windows 95
; 951 = Windows 95A (OSR 1.0)
;1057 = Windows NT 3.51
;1111 = Windows 95B (OSR 2.0)
;1212 = Windows 95B (OSR 2.1)
;1214 = Windows 95C (OSR 2.5)
;1381 = Windows NT 4.0
;1998 = Windows 98 (Final Release)
;2195 = Windows 2000
;2222 = Windows 98 (Second Edition)
;2600 = Windows XP (alt auch 2505)
;3000 = Windows ME
;3790 = Windows XP 64-Bit, Windows Home Server oder Windows Server 2003
;6000 = Windows Vista
;6001 = Windows Server 2008
;--------
;PlatformId:
;0 = VER_PLATFORM_WIN32s
;1 = VER_PLATFORM_WIN32_WINDOWS
;2 = VER_PLATFORM_WIN32_NT
;--------
;CSDVersion:
;Aktuelles Servive-Pack als String (keines = Leerstring)
;--------
;ServicePackMajor:
;Hauptversion des Service-Packs
;--------
;ServicePackMinor:
;Unterversion des Service-Packs
;--------
;SuiteMask:
;Bit-Maske zur Ermittlung von Suites
;$00000001 = VER_SUITE_SMALLBUSINESS = Microsoft Small Business Server war mal installiert, ist aber möglicherweise geupdatet worden
;$00000002 = VER_SUITE_ENTERPRISE = Windows Server 2008 Enterprise, Windows Server 2003 Enterprise Edition oder Windows 2000 Advanced Server ist installiert
;$00000004 = VER_SUITE_BACKOFFICE = Microsoft BackOffice-Komponenten sind installiert
;$00000008 = VER_SUITE_COMMUNICATIONS
;$00000010 = VER_SUITE_TERMINAL = Terminal-Services sind installiert
;$00000020 = VER_SUITE_SMALLBUSINESS_RESTRICTED = Microsoft Small Business Server ist installiert mit einer restriktiven Client-Lizenz
;$00000040 = VER_SUITE_EMBEDDEDNT = Windows XP Embedded ist installiert
;$00000080 = VER_SUITE_DATACENTER = Windows Server 2008 Datacenter, Windows Server 2003 Datacenter Edition oder Windows 2000 Datacenter Server ist installiert
;$00000100 = VER_SUITE_SINGLEUSERTS = Allgemein: Remote-Desktop wird unterstützt, aber nur mit einer interaktiven Session
;$00000200 = VER_SUITE_PERSONAL = Windows Vista Home Premium, Windows Vista Home Basic oder Windows XP Home Edition ist installiert
;$00000400 = VER_SUITE_BLADE = Windows Server 2003 Web Edition ist installiert
;$00000800 = VER_SUITE_EMBEDDED_RESTRICTED
;$00001000 = VER_SUITE_SECURITY_APPLIANCE
;$00002000 = VER_SUITE_STORAGE_SERVER = Windows Storage Server 2003 R2 oder Windows Storage Server 2003 ist installiert
;$00004000 = VER_SUITE_COMPUTE_SERVER = Windows Server 2003 Compute Cluster Edition ist installiert
;$00008000 = VER_SUITE_WH_SERVER = Windows Home Server ist installiert
;--------
;ProductType:
;1 = VER_NT_WORKSTATION = Windows Vista, Windows XP Professional, Windows XP Home Edition oder Windows 2000 Professional
;2 = VER_NT_DOMAIN_CONTROLLER = Windows Server 2008, Windows Server 2003 oder Windows 2000 Server
;3 = VER_NT_SERVER = Windows Server 2008, Windows Server 2003 oder Windows 2000 Server
;--------------------------------------------------------------------------------------------------

#VER_SUITE_ENTERPRISE     =   $2
#VER_SUITE_EMBEDDEDNT     =  $40
#VER_SUITE_DATACENTER     =  $80
#VER_SUITE_PERSONAL       = $200
#VER_NT_WORKSTATION       =   $1
#VER_NT_DOMAIN_CONTROLLER =   $2
#VER_NT_SERVER            =   $3

OSVI.OSVERSIONINFOEX         ;ist PB-Struktur, s.o.
OSVI\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX)    ;erstmal die benötigte Struktur-Größe eingeben

If GetVersionEx_(@OSVI) And OSVI\dwPlatformId = #VER_PLATFORM_WIN32_NT    ;Angaben ermitteln 
  MaV$ = "MajorVersion : " + Str(OSVI\dwMajorVersion) + #LFCR$ 
  MiV$ = "MinorVersion : " + Str(OSVI\dwMinorVersion) + #LFCR$
  BNr$ = "BuildNumber : " + Str(OSVI\dwBuildNumber) + #LFCR$
  PId$ = "PlatformId : " + Str(OSVI\dwPlatformId) + #LFCR$
  SP$ = "SP$ : " + PeekS(@OSVI\szCSDVersion) + #LFCR$
  SPMa$ = "SP-MajorVersion : " + Str(OSVI\wServicePackMajor) + #LFCR$
  SPMi$ = "SP-MinorVersion : " + Str(OSVI\wServicePackMinor) + #LFCR$
  SM$ = "SuiteMask : $" + Hex(OSVI\wSuiteMask) + #LFCR$
  PrT$ = "ProductType : " + Str(OSVI\wProductType) + #LFCR$ + #LFCR$
  
  SuiteMask = OSVI\wSuiteMask
  
  Select OSVI\dwMajorVersion
    Case 4
      OS$ = "Windows NT 4.0 "
    Case 5                   ;Windows Server 2003 R2, Windows Server 2003, Windows XP oder Windows 2000
      Select OSVI\dwMinorVersion
        Case 0               ;W2k
          OS$ = "Windows 2000 "
            Select SuiteMask & (#VER_SUITE_DATACENTER | #VER_SUITE_ENTERPRISE) ;$82
              Case #VER_SUITE_ENTERPRISE
                OS$ + "Advanced Server "
              Case #VER_SUITE_DATACENTER  
                OS$ + "Datacenter Server "
              Default
                OS$ + "Professional "
            EndSelect 
        Case 1               ;XP
          OS$ = "Windows XP "
            Select SuiteMask & (#VER_SUITE_PERSONAL | #VER_SUITE_EMBEDDEDNT)   ;$240
              Case #VER_SUITE_EMBEDDEDNT
                OS$ + "Embedded " 
              Case #VER_SUITE_PERSONAL
                OS$ + "Home Edition "
              Default
                OS$ + "Professional "         
            EndSelect 
        Case 2               ;Windows Server 2003 R2, Windows Server 2003 oder Windows XP Professional x64 Edition
          Select OSVI\wProductType
            Case #VER_NT_WORKSTATION
              OS$ = "Windows XP Professional x64 Edition "
            Case #VER_NT_DOMAIN_CONTROLLER, #VER_NT_SERVER
              Select GetSystemMetrics_(#SM_SERVERR2)
                Case 0
                  OS$ = "Windows Server 2003 "
                Default
                  OS$ = "Windows Server 2003 R2 "
              EndSelect         
          EndSelect
      EndSelect 
    Case 6                   ;Windows Vista oder Windows Server 2008 
      Select OSVI\wProductType
        Case #VER_NT_WORKSTATION
          OS$ = "Windows Vista "
            Select SuiteMask & #VER_SUITE_PERSONAL
              Case #VER_SUITE_PERSONAL
                OS$ + "Home "
            EndSelect
        Case #VER_NT_DOMAIN_CONTROLLER, #VER_NT_SERVER
          OS$ = "Windows Server 2008 "
      EndSelect 
  EndSelect 
 
  OS$ + PeekS(@OSVI\szCSDVersion)      ;Service-Pack anhängen
  Result$ = MaV$ + MiV$ + BNr$ + PId$ + SP$ + SPMa$ + SPMi$ + SM$ + PrT$ + OS$

 Else 
  Result$ = "Ermittlung fehlgeschlagen oder keine WIN-32-NT-Version !"
EndIf

MessageRequester("Windows-Betriebssystem", Result$)
Gruß
Helle
Benutzeravatar
Scarabol
Beiträge: 1427
Registriert: 30.11.2005 21:00

Beitrag von Scarabol »

Wow nice! :allright:

Wird sofort der Include Sammlung hinzugefügt :)

Gruß
Scarabol
Abgeschlossen Projekte:
Schreibmaschine, Bildschirmlupe, Wings3DtoOgreMeshConverter
Watch: PureArea

PB-V: 4
WinXP
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

Funzt :allright:
---------------------------
Windows-Betriebssystem
---------------------------
MajorVersion : 5

MinorVersion : 1

BuildNumber : 2600

PlatformId : 2

SP$ : Service Pack 3, v.3264

SP-MajorVersion : 3

SP-MinorVersion : 0

SuiteMask : $100

ProductType : 1



Windows XP Professional Service Pack 3, v.3264
---------------------------
OK
---------------------------
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
Helle
Beiträge: 566
Registriert: 11.11.2004 16:13
Wohnort: Magdeburg

Re: Betriebssystem-Informationen

Beitrag von Helle »

Allerhöchste Zeit für ein Update (Windows) :mrgreen: :

Code: Alles auswählen

;Vorhandenes Windows-Betriebssystem und Zusatz-Informationen ermitteln
;Gilt ab Windows 2000

Global ReturnedProductType.l
#PROCESSOR_ARCHITECTURE_AMD64 = $0009  ;für Test, ob 32- oder 64-Bit-OS
Dim ProductType.s(103)       ;dies gilt ab Vista           
  ProductType(0) = "Unknown Product "
  ProductType(1) = "Ultimate "
  ProductType(2) = "Home Basic "
  ProductType(3) = "Home Premium "
  ProductType(4) = "Enterprise "
  ProductType(5) = "Home Basic N "
  ProductType(6) = "Business "
  ProductType(7) = "Server Standard "
  ProductType(8) = "Server Datacenter (full installation) "
  ProductType(9) = "Windows Small Business Server "
  ProductType(10) = "Server Enterprise (full installation) "
  ProductType(11) = "Starter "
  ProductType(12) = "Server Datacenter (core installation) "
  ProductType(13) = "Server Standard (core installation) "
  ProductType(14) = "Server Enterprise (core installation) "
  ProductType(15) = "Server Enterprise for Itanium-based Systems "
  ProductType(16) = "Business N "
  ProductType(17) = "Web Server (full installation) "
  ProductType(18) = "HPC Edition "
  ProductType(19) = "Windows Storage Server 2008 R2 Essentials "
  ProductType(20) = "Storage Server Express "
  ProductType(21) = "Storage Server Standard "
  ProductType(22) = "Storage Server Workgroup "
  ProductType(23) = "Storage Server Enterprise "
  ProductType(24) = "Windows Server 2008 for Windows Essential Server Solutions "
  ProductType(25) = "Small Business Server Premium "
  ProductType(26) = "Home Premium N "
  ProductType(27) = "Enterprise N "
  ProductType(28) = "Ultimate N "
  ProductType(29) = "Web Server (core installation) "
  ProductType(30) = "Windows Essential Business Server Management Server "
  ProductType(31) = "Windows Essential Business Server Security Server "
  ProductType(32) = "Windows Essential Business Server Messaging Server "
  ProductType(33) = ""
  ProductType(34) = "Windows Home Server 2011 "
  ProductType(35) = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions "
  ProductType(36) = "Server Standard without Hyper-V "
  ProductType(37) = "Server Datacenter without Hyper-V (full installation) "
  ProductType(38) = "Server Enterprise without Hyper-V (full installation) "
  ProductType(39) = "Server Datacenter without Hyper-V (core installation) "
  ProductType(40) = "Server Standard without Hyper-V (core installation) "
  ProductType(41) = "Server Enterprise without Hyper-V (core installation) "
  ProductType(42) = "Microsoft Hyper-V Server "
  ProductType(43) = "Storage Server Express (core installation) "
  ProductType(44) = "Storage Server Standard (core installation) "
  ProductType(45) = "Storage Server Workgroup (core installation) "
  ProductType(46) = "Storage Server Enterprise (core installation) "
  ProductType(47) = "Starter N "
  ProductType(48) = "Professional "
  ProductType(49) = "Professional N "
  ProductType(50) = ""
  ProductType(51) = "Server for SB Solutions "
  ProductType(52) = "Server Solutions Premium "
  ProductType(53) = "Server Solutions Premium (core installation) "
  ProductType(54) = "Server for SB Solutions EM "
  ProductType(55) = "Server for SB Solutions EM "
  ProductType(56) = "Windows MultiPoint Server "
  ProductType(57) = ""
  ProductType(58) = ""
  ProductType(59) = "Windows Essential Server Solution Management "
  ProductType(60) = "Windows Essential Server Solution Additional "
  ProductType(61) = "Windows Essential Server Solution Management SVC "
  ProductType(62) = "Windows Essential Server Solution Additional SVC "
  ProductType(63) = "Small Business Server Premium (core installation) "
  ProductType(64) = "Server Hyper Core V "
  ProductType(65) = ""
  ProductType(66) = "Not supported "
  ProductType(67) = "Not supported "
  ProductType(68) = "Not supported "
  ProductType(69) = "Not supported "
  ProductType(70) = "Not supported "
  ProductType(71) = "Not supported "
  ProductType(72) = "Server Enterprise (evaluation installation) "
  ProductType(73) = ""
  ProductType(74) = ""
  ProductType(75) = ""
  ProductType(76) = "Windows MultiPoint Server Standard (full installation) "
  ProductType(77) = "Windows MultiPoint Server Premium (full installation) "
  ProductType(78) = ""
  ProductType(79) = "Server Standard (evaluation installation) "
  ProductType(80) = "Server Datacenter (evaluation installation) "
  ProductType(81) = ""
  ProductType(82) = ""
  ProductType(83) = ""
  ProductType(84) = "Enterprise N (evaluation installation) "
  ProductType(85) = ""
  ProductType(86) = ""
  ProductType(87) = ""
  ProductType(88) = ""
  ProductType(89) = ""
  ProductType(90) = ""
  ProductType(91) = ""
  ProductType(92) = ""
  ProductType(93) = ""
  ProductType(94) = ""
  ProductType(95) = "Storage Server Workgroup (evaluation installation) "
  ProductType(96) = "Storage Server Standard (evaluation installation) "
  ProductType(97) = ""
  ProductType(98) = "N "
  ProductType(99) = "China "
  ProductType(100) = "Single Language "
  ProductType(101) = ""
  ProductType(102) = ""
  ProductType(103) = "Professional with Media Center "

OSVI.OSVERSIONINFOEX         ;ist PB-Struktur
OSVI\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX)    ;Struktur-Größe setzen

S_I.SYSTEM_INFO              ;ist PB-Struktur
If OSVersion() > #PB_OS_Windows_2000   ;Mit W2k geht nachfolgende Abfrage nicht (gibt ja auch kein 64-Bit-W2k)! 
  openlib = OpenLibrary(#PB_Any, "kernel32.dll") 
  *GetNativeSystemInfo = GetFunction(openlib, "GetNativeSystemInfo") 
  CallFunctionFast(*GetNativeSystemInfo, @S_I) 
  CloseLibrary(openlib) 
  If S_I\wProcessorArchitecture = #PROCESSOR_ARCHITECTURE_AMD64 
    OS3264$ = "64-Bit"
   Else
    OS3264$ = "32-Bit"
  EndIf 
EndIf   

OpenLibrary(0, "Kernel32.dll")
Prototype.l ProtoKernel32_5(V1.l, V2.l, V3.l, V4.l, V5.l)
Kernel32.ProtoKernel32_5 = GetFunction(0, "GetProductInfo") 

If GetVersionEx_(@OSVI) And OSVI\dwPlatformId = #VER_PLATFORM_WIN32_NT    ;Angaben ermitteln
  MaV$ = "MajorVersion : " + Str(OSVI\dwMajorVersion) + #LFCR$
  MiV$ = "MinorVersion : " + Str(OSVI\dwMinorVersion) + #LFCR$
  BNr$ = "BuildNumber : " + Str(OSVI\dwBuildNumber) + #LFCR$
  SP$ = "SP$ : " + PeekS(@OSVI\szCSDVersion) + #LFCR$
  SPMa$ = "SP-MajorVersion : " + Str(OSVI\wServicePackMajor) + #LFCR$
  SPMi$ = "SP-MinorVersion : " + Str(OSVI\wServicePackMinor) + #LFCR$

  Select OSVI\dwMajorVersion
    Case 5                   ;Windows Server 2003 R2, Windows Server 2003, Windows XP, Windows 2000
      Select OSVI\dwMinorVersion
        Case 0               ;W2k
          OS$ = "Windows 2000 "
            Select OSVI\wSuiteMask & (#VER_SUITE_DATACENTER | #VER_SUITE_ENTERPRISE)
              Case #VER_SUITE_ENTERPRISE
                OS$ + "Advanced Server "
              Case #VER_SUITE_DATACENTER 
                OS$ + "Datacenter Server "
              Default
                OS$ + "Professional "
            EndSelect
        Case 1               ;XP
          OS$ = "Windows XP "
            Select OSVI\wSuiteMask & (#VER_SUITE_PERSONAL | #VER_SUITE_EMBEDDEDNT)
              Case #VER_SUITE_EMBEDDEDNT
                OS$ + "Embedded "
              Case #VER_SUITE_PERSONAL
                OS$ + "Home Edition "
              Default
                OS$ + "Professional "         
            EndSelect
        Case 2               ;Windows Server 2003 R2, Windows Server 2003, Windows XP Professional x64 Edition
          Select OSVI\wProductType
            Case #VER_NT_WORKSTATION
              OS$ = "Windows XP Professional x64 Edition "
            Case #VER_NT_DOMAIN_CONTROLLER, #VER_NT_SERVER
              Select GetSystemMetrics_(#SM_SERVERR2)
                Case 0
                  OS$ = "Windows Server 2003 "
                Default
                  OS$ = "Windows Server 2003 R2 "
              EndSelect         
          EndSelect
      EndSelect
      OS$ + PeekS(@OSVI\szCSDVersion) + #LFCR$   ;Service-Pack anhängen
    Case 6                   ;Vista, 7, 8, 8.1
      OS$ = "Base: "
      Kernel32(OSVI\dwMajorVersion, OSVI\dwMinorVersion, OSVI\wServicePackMajor, OSVI\wServicePackMinor, @ReturnedProductType)
      Select OSVI\dwMinorVersion
        Case 0               ;Vista
          OS$ + "Windows Vista "
        Case 1               ;7
          OS$ + "Windows 7 "
        Case 2               ;8
          OS$ + "Windows 8 "
      EndSelect
      OS$ + PeekS(@OSVI\szCSDVersion) + #LFCR$ + "Type: " + ProductType(ReturnedProductType) + OS3264$     
  EndSelect
  Result$ = MaV$ + MiV$ + BNr$ + SP$ + SPMa$ + SPMi$ + #LFCR$ + OS$  
 Else
  Result$ = "Ermittlung fehlgeschlagen oder unbekannte (zu alte/zu neue) Windows-Version !"
EndIf
CloseLibrary(0)
MessageRequester("Windows-Betriebssystem", Result$)

Viel Spaß!

P.S.:
Fehler, Unstimmigkeiten usw. bitte melden. Danke!

Edit 8.3.2015: Gültigkeit eingeschränkt auf W2k-W8. Muss wegen W8.1 neu werden.
Zuletzt geändert von Helle am 08.03.2015 16:23, insgesamt 2-mal geändert.
Benutzeravatar
_JON_
Beiträge: 389
Registriert: 30.03.2010 15:24

Re: Betriebssystem-Informationen

Beitrag von _JON_ »

Danke, sehr nützlich.

Für 8.1 und neuer muss aber auf RtlGetVersion umgestiegen werden.
Microsoft hat leider GetVersionEx_() mit windows 8.1 kaputt gemacht :lol:

http://www.purebasic.fr/english/viewtop ... 21#p431121
PureBasic 5.46 LTS (Windows x86/x64) | windows 10 x64 Oktober failure
Benutzeravatar
Helle
Beiträge: 566
Registriert: 11.11.2004 16:13
Wohnort: Magdeburg

Re: Betriebssystem-Informationen

Beitrag von Helle »

Danke _JON_! Das ist mir als W7-Nutzer glatt entgangen :oops: . Schaue ich mir morgen mal in Ruhe an und suche Anfang nächste Woche auf Arbeit einen PC mit 8.1 zum Praxis-Test.
Also, Leute, obiger Code gilt nur für Windows bis einschließlich 8 (nicht für 8.1).
Sorry!
Helle
Benutzeravatar
tft
Beiträge: 605
Registriert: 08.09.2004 20:18
Computerausstattung: GTX Titan , i9 9900K , 32 GB Ram , 500 GB SSD , 3 ASUS FullHD Monitore and more
Wohnort: Dachsen
Kontaktdaten:

Re: Betriebssystem-Informationen

Beitrag von tft »

Hallo,

bisher war das hier echt cool. Aber seit Windows 8.1 geht es ja nicht mehr. Hat jemand
ne Idee für Windows ab 8?

Gruss TFT
TFT seid 1989 , Turgut Frank Temucin , Dachsen/Berlin/Antalya
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMAgic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak :-)
Benutzeravatar
_JON_
Beiträge: 389
Registriert: 30.03.2010 15:24

Re: Betriebssystem-Informationen

Beitrag von _JON_ »

Mal schnell zusammen gesetzt, sollte aber etwas getestet werden.

Code: Alles auswählen

;Vorhandenes Windows-Betriebssystem und Zusatz-Informationen ermitteln
;Gilt ab Windows 2000

Global ReturnedProductType.l
#PROCESSOR_ARCHITECTURE_AMD64 = $0009  ;für Test, ob 32- oder 64-Bit-OS
Dim ProductType.s(103)       ;dies gilt ab Vista           
  ProductType(0) = "Unknown Product "
  ProductType(1) = "Ultimate "
  ProductType(2) = "Home Basic "
  ProductType(3) = "Home Premium "
  ProductType(4) = "Enterprise "
  ProductType(5) = "Home Basic N "
  ProductType(6) = "Business "
  ProductType(7) = "Server Standard "
  ProductType(8) = "Server Datacenter (full installation) "
  ProductType(9) = "Windows Small Business Server "
  ProductType(10) = "Server Enterprise (full installation) "
  ProductType(11) = "Starter "
  ProductType(12) = "Server Datacenter (core installation) "
  ProductType(13) = "Server Standard (core installation) "
  ProductType(14) = "Server Enterprise (core installation) "
  ProductType(15) = "Server Enterprise for Itanium-based Systems "
  ProductType(16) = "Business N "
  ProductType(17) = "Web Server (full installation) "
  ProductType(18) = "HPC Edition "
  ProductType(19) = "Windows Storage Server 2008 R2 Essentials "
  ProductType(20) = "Storage Server Express "
  ProductType(21) = "Storage Server Standard "
  ProductType(22) = "Storage Server Workgroup "
  ProductType(23) = "Storage Server Enterprise "
  ProductType(24) = "Windows Server 2008 for Windows Essential Server Solutions "
  ProductType(25) = "Small Business Server Premium "
  ProductType(26) = "Home Premium N "
  ProductType(27) = "Enterprise N "
  ProductType(28) = "Ultimate N "
  ProductType(29) = "Web Server (core installation) "
  ProductType(30) = "Windows Essential Business Server Management Server "
  ProductType(31) = "Windows Essential Business Server Security Server "
  ProductType(32) = "Windows Essential Business Server Messaging Server "
  ProductType(33) = ""
  ProductType(34) = "Windows Home Server 2011 "
  ProductType(35) = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions "
  ProductType(36) = "Server Standard without Hyper-V "
  ProductType(37) = "Server Datacenter without Hyper-V (full installation) "
  ProductType(38) = "Server Enterprise without Hyper-V (full installation) "
  ProductType(39) = "Server Datacenter without Hyper-V (core installation) "
  ProductType(40) = "Server Standard without Hyper-V (core installation) "
  ProductType(41) = "Server Enterprise without Hyper-V (core installation) "
  ProductType(42) = "Microsoft Hyper-V Server "
  ProductType(43) = "Storage Server Express (core installation) "
  ProductType(44) = "Storage Server Standard (core installation) "
  ProductType(45) = "Storage Server Workgroup (core installation) "
  ProductType(46) = "Storage Server Enterprise (core installation) "
  ProductType(47) = "Starter N "
  ProductType(48) = "Professional "
  ProductType(49) = "Professional N "
  ProductType(50) = ""
  ProductType(51) = "Server for SB Solutions "
  ProductType(52) = "Server Solutions Premium "
  ProductType(53) = "Server Solutions Premium (core installation) "
  ProductType(54) = "Server for SB Solutions EM "
  ProductType(55) = "Server for SB Solutions EM "
  ProductType(56) = "Windows MultiPoint Server "
  ProductType(57) = ""
  ProductType(58) = ""
  ProductType(59) = "Windows Essential Server Solution Management "
  ProductType(60) = "Windows Essential Server Solution Additional "
  ProductType(61) = "Windows Essential Server Solution Management SVC "
  ProductType(62) = "Windows Essential Server Solution Additional SVC "
  ProductType(63) = "Small Business Server Premium (core installation) "
  ProductType(64) = "Server Hyper Core V "
  ProductType(65) = ""
  ProductType(66) = "Not supported "
  ProductType(67) = "Not supported "
  ProductType(68) = "Not supported "
  ProductType(69) = "Not supported "
  ProductType(70) = "Not supported "
  ProductType(71) = "Not supported "
  ProductType(72) = "Server Enterprise (evaluation installation) "
  ProductType(73) = ""
  ProductType(74) = ""
  ProductType(75) = ""
  ProductType(76) = "Windows MultiPoint Server Standard (full installation) "
  ProductType(77) = "Windows MultiPoint Server Premium (full installation) "
  ProductType(78) = ""
  ProductType(79) = "Server Standard (evaluation installation) "
  ProductType(80) = "Server Datacenter (evaluation installation) "
  ProductType(81) = ""
  ProductType(82) = ""
  ProductType(83) = ""
  ProductType(84) = "Enterprise N (evaluation installation) "
  ProductType(85) = ""
  ProductType(86) = ""
  ProductType(87) = ""
  ProductType(88) = ""
  ProductType(89) = ""
  ProductType(90) = ""
  ProductType(91) = ""
  ProductType(92) = ""
  ProductType(93) = ""
  ProductType(94) = ""
  ProductType(95) = "Storage Server Workgroup (evaluation installation) "
  ProductType(96) = "Storage Server Standard (evaluation installation) "
  ProductType(97) = ""
  ProductType(98) = "N "
  ProductType(99) = "China "
  ProductType(100) = "Single Language "
  ProductType(101) = ""
  ProductType(102) = ""
  ProductType(103) = "Professional with Media Center "

OSVI.OSVERSIONINFOEX         ;ist PB-Struktur
OSVI\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX)    ;Struktur-Größe setzen

S_I.SYSTEM_INFO              ;ist PB-Struktur
If OSVersion() > #PB_OS_Windows_2000   ;Mit W2k geht nachfolgende Abfrage nicht (gibt ja auch kein 64-Bit-W2k)! 
  openlib = OpenLibrary(#PB_Any, "kernel32.dll") 
  *GetNativeSystemInfo = GetFunction(openlib, "GetNativeSystemInfo") 
  CallFunctionFast(*GetNativeSystemInfo, @S_I) 
  CloseLibrary(openlib) 
  If S_I\wProcessorArchitecture = #PROCESSOR_ARCHITECTURE_AMD64 
    OS3264$ = "64-Bit"
   Else
    OS3264$ = "32-Bit"
  EndIf 
EndIf   

OpenLibrary(0, "Kernel32.dll")
Prototype.l ProtoKernel32_5(V1.l, V2.l, V3.l, V4.l, V5.l)
Kernel32.ProtoKernel32_5 = GetFunction(0, "GetProductInfo") 
CloseLibrary(0)

Prototype pRtlGetVersion(a)
OpenLibrary(0, "ntdll.dll")
RtlGetVersion_.pRtlGetVersion = GetFunction(0, "RtlGetVersion")
CloseLibrary(0)

If RtlGetVersion_ And RtlGetVersion_(@OSVI) = 0 And OSVI\dwPlatformId = #VER_PLATFORM_WIN32_NT    ;Angaben ermitteln
  MaV$ = "MajorVersion : " + Str(OSVI\dwMajorVersion) + #LFCR$
  MiV$ = "MinorVersion : " + Str(OSVI\dwMinorVersion) + #LFCR$
  BNr$ = "BuildNumber : " + Str(OSVI\dwBuildNumber) + #LFCR$
  
  If OSVI\dwMajorVersion < 8
    SP$ = "SP$ : " + PeekS(@OSVI\szCSDVersion) + #LFCR$
    SPMa$ = "SP-MajorVersion : " + Str(OSVI\wServicePackMajor) + #LFCR$
    SPMi$ = "SP-MinorVersion : " + Str(OSVI\wServicePackMinor) + #LFCR$
  EndIf
  
  
  Select OSVI\dwMajorVersion
    Case 5                   ;Windows Server 2003 R2, Windows Server 2003, Windows XP, Windows 2000
      Select OSVI\dwMinorVersion
        Case 0               ;W2k
          OS$ = "Windows 2000 "
            Select OSVI\wSuiteMask & (#VER_SUITE_DATACENTER | #VER_SUITE_ENTERPRISE)
              Case #VER_SUITE_ENTERPRISE
                OS$ + "Advanced Server "
              Case #VER_SUITE_DATACENTER 
                OS$ + "Datacenter Server "
              Default
                OS$ + "Professional "
            EndSelect
        Case 1               ;XP
          OS$ = "Windows XP "
            Select OSVI\wSuiteMask & (#VER_SUITE_PERSONAL | #VER_SUITE_EMBEDDEDNT)
              Case #VER_SUITE_EMBEDDEDNT
                OS$ + "Embedded "
              Case #VER_SUITE_PERSONAL
                OS$ + "Home Edition "
              Default
                OS$ + "Professional "         
            EndSelect
        Case 2               ;Windows Server 2003 R2, Windows Server 2003, Windows XP Professional x64 Edition
          Select OSVI\wProductType
            Case #VER_NT_WORKSTATION
              OS$ = "Windows XP Professional x64 Edition "
            Case #VER_NT_DOMAIN_CONTROLLER, #VER_NT_SERVER
              Select GetSystemMetrics_(#SM_SERVERR2)
                Case 0
                  OS$ = "Windows Server 2003 "
                Default
                  OS$ = "Windows Server 2003 R2 "
              EndSelect         
          EndSelect
      EndSelect
      OS$ + PeekS(@OSVI\szCSDVersion) + #LFCR$   ;Service-Pack anhängen
    Case 6                   ;Vista, 7, 8, 8.1
      OS$ = "Base: "
      Kernel32(OSVI\dwMajorVersion, OSVI\dwMinorVersion, OSVI\wServicePackMajor, OSVI\wServicePackMinor, @ReturnedProductType)
      Select OSVI\dwMinorVersion
        Case 0               ;Vista
          OS$ + "Windows Vista "
        Case 1               ;7
          OS$ + "Windows 7 "
        Case 2               ;8
          OS$ + "Windows 8 "
        Case 3
          OS$ + "Windows 8.1 "
      EndSelect
      OS$ + PeekS(@OSVI\szCSDVersion) + #LFCR$ + "Type: " + ProductType(ReturnedProductType) + OS3264$     
      
    Case 10
      OS$ = "Base: "
      Kernel32(OSVI\dwMajorVersion, OSVI\dwMinorVersion, OSVI\wServicePackMajor, OSVI\wServicePackMinor, @ReturnedProductType)
      Select OSVI\dwMinorVersion
        Case 0
          OS$ + "Windows 10 "        
      EndSelect
      OS$ + PeekS(@OSVI\szCSDVersion) + #LFCR$ + "Type: " + ProductType(ReturnedProductType) + OS3264$     
      
  EndSelect
  Result$ = MaV$ + MiV$ + BNr$ + SP$ + SPMa$ + SPMi$ + #LFCR$ + OS$  
 Else
  Result$ = "Ermittlung fehlgeschlagen oder unbekannte (zu alte/zu neue) Windows-Version !"
EndIf
MessageRequester("Windows-Betriebssystem", Result$)
PureBasic 5.46 LTS (Windows x86/x64) | windows 10 x64 Oktober failure
Antworten