[Implemented] OSVersion() Update?
[Implemented] OSVersion() Update?
When is the OSVersion() going to be updated with the #PB_OS_Windows_Vista constant?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
I wrote alittle code here that'll help me while I wait for an update of the OSVersion() procedure:
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() + ".")
Last edited by GeoTrail on Tue Nov 14, 2006 10:07 pm, edited 1 time in total.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
For those how don't use the Droopy lib :
Dri
Code: Select all
Macro GetWindowsDirectory()
GetEnvironmentVariable("windir")
EndMacro
Why not use #PB_OS_Windows_Future until there is no real constant? 

PB 4.30
Code: Select all
onErrorGoto(?Fred)
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?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
-
- Enthusiast
- Posts: 372
- Joined: Sun Apr 03, 2005 2:14 am
- Location: England
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
GeoTrail, could you run this on your Vista and see what you get, I'd be interested to know:
Presumably testing for some of the data this API returns would be a fairly reliable way to test. 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
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)
Here's the result netmaestro:
hehehe
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.

I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
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())

edit: typos removed.
edit2: added NT3 detection and changed "Windows Server Longhorn" to "Windows Server 2008" its now the official name by microsoft. i am not sure if the NT3 detection will work properly, i dont have any chance to test it.
c ya,
nco2k
Last edited by nco2k on Wed Nov 22, 2006 8:50 pm, edited 2 times in total.
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
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)
Even, if you don't want to use the Future-constant, there is an other way to detect Vista, Although, there is no vista-constant:
Did you already recognize, the the values of these constants are sorted ascending?
The newer the OS version is, the higher is the value of the constant. This means, that
Code: Select all
If OSVersion() > #PB_OS_Windows_Server_2003
Debug "Your OS is newer than Win2003"
EndIf
I hope, you know that I'm aiming at in this post.
PB 4.30
Code: Select all
onErrorGoto(?Fred)