[Implemented] OSVersion() Update?
Posted: Tue Nov 14, 2006 3:49 pm
When is the OSVersion() going to be updated with the #PB_OS_Windows_Vista constant?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure.s GetOSVersion()
Macro GetWindowsDirectory()
GetEnvironmentVariable("windir")
EndMacro
WinDir$ = GetWindowsDirectory()+"\"
Select OSVersion()
Case #PB_OS_Windows_NT3_51
Result$ = "Windows NT 3.51"
Case #PB_OS_Windows_95
Result$ = "Windows 95"
Case #PB_OS_Windows_NT_4
Result$ = "Windows NT 4"
Case #PB_OS_Windows_98
Result$ = "Windows 98"
Case #PB_OS_Windows_ME
Result$ = "Windows ME"
Case #PB_OS_Windows_2000
Result$ = "Windows 2000"
Case #PB_OS_Windows_XP
Result$ = "Windows XP"
Case #PB_OS_Windows_Server_2003
Result$ = "Windows Server 2003"
Case #PB_OS_Windows_Future
If FileSize(WinDir$+"HomePremium.xml")
Result$ = "Windows Vista Home Premium"
ElseIf FileSize(WinDir$+"HomeBasic.xml")
Result$ = "Windows Vista Home Basic"
ElseIf FileSize(WinDir$+"HomeBasicN.xml")
Result$ = "Windows Vista Home BasicN"
ElseIf FileSize(WinDir$+"Business.xml")
Result$ = "Windows Vista Business"
ElseIf FileSize(WinDir$+"BusinessN.xml")
Result$ = "Windows Vista BusinessN"
ElseIf FileSize(WinDir$+"Ultimate.xml")
Result$ = "Windows Vista Ultimate"
ElseIf FileSize(WinDir$+"Starter.xml")
Result$ = "Windows Vista Starter"
Else
Result$ = "Windows Vista"
EndIf
EndSelect
ProcedureReturn Result$
EndProcedure
MessageRequester("Windows Version Checker", "This is a test app for " + GetOSVersion() + ".")
Code: Select all
Macro GetWindowsDirectory()
GetEnvironmentVariable("windir")
EndMacro
I've updated my codeDr. Dri wrote:For those how don't use the Droopy lib :DriCode: Select all
Macro GetWindowsDirectory() GetEnvironmentVariable("windir") EndMacro
I don't, but if they did, then the old file would be deleted and replaced with the newly upgraded versionTrond wrote:How do you know the user doesn't have more of those xml files after an upgrade, for example from home to premium?
What do you mean?AND51 wrote:Why not use #PB_OS_Windows_Future until there is no real constant?
Code: Select all
vi.OSVERSIONINFO
vi\dwOsVersionInfoSize = SizeOf(OSVERSIONINFO)
GetVersionEx_(@vi)
out$ = "Major Version: "+Str(vi\dwMajorVersion)+ #CRLF$
out$ + "Minor Version: "+Str(vi\dwMinorVersion) + #CRLF$
out$ + "Build Number: "+Str(vi\dwBuildNumber) + #CRLF$
out$ + "Platform ID: "+Str(vi\dwPlatformId) + #CRLF$
out$ + PeekS(@vi\szCSDversion) + #CRLF$
MessageRequester("OS Version Information:",out$,#MB_ICONINFORMATION)
Major Version: 6
Minor Version: 0
Build Number: 6000
Platform ID: 2
Yeah that's what my girlfriend said about rubber over three years agonetmaestro wrote:I get a little nervous about looking on the disk for specific files, it just doesn't seem like a very bulletproof approach to me.
Code: Select all
Procedure.s MyOSVersion()
Result.s = "Windows Unknown"
osvi.OSVERSIONINFO
osvi\dwOsVersionInfoSize = SizeOf(OSVERSIONINFO)
If GetVersionEx_(@osvi)
Select osvi\dwPlatformId
Case 1
If osvi\dwMajorVersion = 4
Select osvi\dwMinorVersion
Case 0
Result = "Windows 95"
Case 10
Result = "Windows 98"
Case 90
Result = "Windows ME"
EndSelect
EndIf
Case 2
osviex.OSVERSIONINFOEX
osviex\dwOsVersionInfoSize = SizeOf(OSVERSIONINFOEX)
If GetVersionEx_(@osviex)
Select osviex\dwMajorVersion
Case 3
Result = "Windows NT3"
Case 4
Result = "Windows NT4"
Case 5
Select osviex\dwMinorVersion
Case 0
Result = "Windows 2000"
Case 1
Result = "Windows XP"
Case 2
If osviex\wProductType = 1
Result = "Windows XP";64Bit
Else
Result = "Windows Server 2003"
EndIf
EndSelect
Case 6
Select osviex\dwMinorVersion
Case 0
If osviex\wProductType = 1
Result = "Windows Vista"
Else
Result = "Windows Server 2008"
EndIf
EndSelect
EndSelect
EndIf
EndSelect
EndIf
ProcedureReturn Result
EndProcedure
MessageRequester("OS Version", MyOSVersion())
Please, have a closer look at the help:GeoTrail wrote:What do you mean?AND51 wrote:Why not use #PB_OS_Windows_Future until there is no real constant?
The german annotation says: "New windows version (not existant, when the program was written)PB Help, OSVersion() wrote: #PB_OS_Windows_NT3_51 = 5
#PB_OS_Windows_95 = 10
#PB_OS_Windows_NT_4 = 20
#PB_OS_Windows_98 = 30
#PB_OS_Windows_ME = 40
#PB_OS_Windows_2000 = 50
#PB_OS_Windows_XP = 60
#PB_OS_Windows_Server_2003 = 65
#PB_OS_Windows_Future = 100 ; neue Windows Version (nicht existent, als das Programm geschrieben wurde)
Code: Select all
If OSVersion() > #PB_OS_Windows_Server_2003
Debug "Your OS is newer than Win2003"
EndIf