GetVersionEx (help me test this code)

Everything else that doesn't fall into one of the other PB categories.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

GetVersionEx (help me test this code)

Post by Killswitch »

I've just written a procedure to determine the version of windows someone is running. It works on my machine but I need to test it on different versions of Windows.

Code: Select all


Procedure.s WindowsVersion()

  Version.OSVERSIONINFO
  Version\dwOSVersionInfoSize=SizeOf(OSVERSIONINFO)
  GetVersionEx_(Version)

  Select Version\dwMajorVersion
  
    Case 4 ;Windows NT 4.0, Windows Me, Windows 98, or Windows 95
    
      Select Version\dwMinorVersion
      
        Case 10
          ProcedureReturn "Windows 98"
        
        Case 90
          ProcedureReturn "Windows ME"
        
        Default
        
          If Version\dwPlatformID=#VER_PLATFORM_WIN32_WINDOWS 
            ProcedureReturn "Windows 95"
          EndIf
      
      EndSelect
    
    Case 5 ;Windows Server 2003, Windows XP, or Windows 2000
      
      Select Version\dwMinorVersion
      
        Case 1
          ProcedureReturn "Windows XP"
      
        Case 2
          ProcedureReturn "Windows Server 2003"
        
        Default
          ProcedureReturn "Windows 2000"
     
      EndSelect
    
  EndSelect
  
EndProcedure

MessageRequester("Version",WindowsVersion())

Could you please test this on your computer, then post the result and your actual OS.

Thanks a lot!

(BTW: Proceedure is free for anyone to use, can't gaurentee it'll work 100% atm).
~I see one problem with your reasoning: the fact is thats not a chicken~
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Correctly reported Win2k for me!

Cheers!
Paid up PB User !
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

'Result = OSVersion()' is in the PureBasic box :?:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> 'Result = OSVersion()' is in the PureBasic box

Yeah, I thought this was an old thread at first. :shock:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Here's the explination:

I'm writing my own (interpreted) BASIC variant in PureBasic. As I am not allowed to wrap any of PBs existing commands (according to the licence and a thread I made about the topic) I basically have to write each of the commands from scratch.

This is where this procedure comes in.
~I see one problem with your reasoning: the fact is thats not a chicken~
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Ah, now we understand. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

PB wrote:Ah, now we understand. :)
So now you're going to post the result ?!

;)
Paid up PB User !
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

It would really help me if you could post your results - espically if your on 95, 98 or ME!
~I see one problem with your reasoning: the fact is thats not a chicken~
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> So now you're going to post the result ?! ;)

Okay :)

Win XP Pro returns Windows XP.
Win 2K Pro returns Windows 2000.
Win 98 SE returns Windows 98.
Win ME returns Windows ME.

Not tested on 95 or NT as I don't have them installed at the moment (obsolete).
If you really need to know the results, let me know and I'll install them...
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Sweet, thank you very much PB - if they all work I'm sure NT and 95 work!
~I see one problem with your reasoning: the fact is thats not a chicken~
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

An updated version, but I'm not sure if Vista and Longhorn works ok. Can anyone confirm?

It seems like the OSVERSIONINFO has change and should contain a "wProductType", or is that in OSVERSIONINFOEX?!?!

Code: Select all

Procedure.s WindowsVersion() 

  Version.OSVERSIONINFO 
  Version\dwOSVersionInfoSize=SizeOf(OSVERSIONINFO) 
  GetVersionEx_(Version) 

  Select Version\dwMajorVersion 

    Case 4 ;Windows NT 4.0, Windows Me, Windows 98, or Windows 95 
      Select Version\dwMinorVersion 
        Case 10 
          ProcedureReturn "Windows 98"  
        Case 90 
          ProcedureReturn "Windows ME" 
        Default 
          If Version\dwPlatformID = #VER_PLATFORM_WIN32_WINDOWS 
            ProcedureReturn "Windows 95"
          ElseIf Version\dwPlatformID = #VER_PLATFORM_WIN32_NT
            ProcedureReturn "Windows NT"
          Else
            ProcedureReturn "Unknown OS"
          EndIf
      EndSelect 
    
    Case 5 ;Windows Server 2003, Windows XP, or Windows 2000 
      Select Version\dwMinorVersion
        Case 0
          ProcedureReturn "Windows 2000"      
        Case 1 
          ProcedureReturn "Windows XP"       
        Case 2 
          ProcedureReturn "Windows Server 2003"         
        Default 
          ProcedureReturn "Unknown OS"       
      EndSelect 

    Case 6 ;Windows Server "Longhorn" or "Microsoft Windows Vista"
      Select Version\dwMinorVersion
        Case 0
          If Version\dwPlatformID = #VER_PLATFORM_WIN32_NT
            ProcedureReturn "Microsoft Windows Vista" 
          Else
            ProcedureReturn "Windows Server Longhorn"
          EndIf
        Default
          ProcedureReturn "Unknown OS"
      EndSelect
  EndSelect 
  
EndProcedure 

MessageRequester("Version",WindowsVersion()) 
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Fine for XP.

Not sure if I still have my vista cd but if it hasn't shown up in a day or so I'll see if i can re-install it (it's pretty much useless, that's why I overwrote the partition).

cheers
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I'm not sure if Vista and Longhorn works

@Fred: Maybe PureBasic's OSVersion() command can be updated to get
these versions of Windows too? ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

PB wrote:> I'm not sure if Vista and Longhorn works

@Fred: Maybe PureBasic's OSVersion() command can be updated to get
these versions of Windows too? ;)
Yeah!

Here is a good link about how to get the new versions, but I'm to lazy to convert it... :lol:

http://msdn.microsoft.com/library/defau ... ersion.asp
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

I should get a chance to re-install vista later today and I'll let you know.

This time I'll keep it available in case there are other questions.

cheers
Post Reply