PC Review


Reply
Thread Tools Rate Thread

Better way to get osversion?

 
 
William Stacey
Guest
Posts: n/a
 
      17th Jan 2004
Is there a better way to get a double (or other) for os version then this?
I want to get os version early in program,
then do checks like: if ( osVersion < 5.2 ) //do something. TIA

int major = Environment.OSVersion.Version.Major;
int minor = Environment.OSVersion.Version.Minor;
try
{
double dver = Double.Parse(major.ToString() + "." + minor.ToString());
return dver;
}
catch
{
//Do something;
}

--
William Stacey, MVP



 
Reply With Quote
 
 
 
 
Justin Rogers
Guest
Posts: n/a
 
      17th Jan 2004
You could just use the Version as is:

For example:

Version targetVersion = new Version(5, 2);
Version osVersion = Environment.OSVersion.Version;

if ( osVersion < targetVersion ) {
}

Note this will be more precise and can take into account builds and revion
numbers as well.

--
Justin Rogers
DigiTec Web Consultants, LLC.

"William Stacey" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Is there a better way to get a double (or other) for os version then this?
> I want to get os version early in program,
> then do checks like: if ( osVersion < 5.2 ) //do something. TIA
>
> int major = Environment.OSVersion.Version.Major;
> int minor = Environment.OSVersion.Version.Minor;
> try
> {
> double dver = Double.Parse(major.ToString() + "." + minor.ToString());
> return dver;
> }
> catch
> {
> //Do something;
> }
>
> --
> William Stacey, MVP
>
>
>



 
Reply With Quote
 
 
 
 
William Stacey
Guest
Posts: n/a
 
      17th Jan 2004
Thanks Justin.

--
William Stacey, MVP

"Justin Rogers" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You could just use the Version as is:
>
> For example:
>
> Version targetVersion = new Version(5, 2);
> Version osVersion = Environment.OSVersion.Version;
>
> if ( osVersion < targetVersion ) {
> }
>
> Note this will be more precise and can take into account builds and revion
> numbers as well.
>
> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
>
> "William Stacey" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Is there a better way to get a double (or other) for os version then

this?
> > I want to get os version early in program,
> > then do checks like: if ( osVersion < 5.2 ) //do something. TIA
> >
> > int major = Environment.OSVersion.Version.Major;
> > int minor = Environment.OSVersion.Version.Minor;
> > try
> > {
> > double dver = Double.Parse(major.ToString() + "." + minor.ToString());
> > return dver;
> > }
> > catch
> > {
> > //Do something;
> > }
> >
> > --
> > William Stacey, MVP
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
It gets better and better Scribner Windows XP General 1 23rd Dec 2004 05:12 PM
Import-Text better? Excel better? KT Microsoft Access 6 28th Oct 2004 03:25 PM
I need a better way or better function than the 'IF' function =?Utf-8?B?aGF2b2NkcmFnb24=?= Microsoft Excel Worksheet Functions 10 17th Aug 2004 10:37 PM
Is InCD better than DirectCD (Drag to disk)? If it is - How is it better? Dmitriy Kopnichev Windows XP Hardware 12 13th Jan 2004 08:12 AM
Which is better (better asked) djc Microsoft Access Form Coding 3 15th Sep 2003 12:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:52 PM.