Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

Get Windows Version (C++.NET 2003 ONLY)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Newbie Coder - 07 Mar 2007 12:46 GMT
C++.NET 2003 ONLY

Hi all,

I need to check to see that the user is using Windows 2000 or later on
program startup. If not, to disable one radiobutton

I have searched Google & all I get is C++ or earlier code, but nothing that
compiles in my version of C++.

There is a KBase article, which isn't any good and is here:

http://support.microsoft.com/kb/307393/EN-US/ but that causes an error due
to the MANAGED CODE needs to be set in Configuration Properties | General
(as I found out & reported to Microsoft)

But of course that isn't what I am looking for. I wrote a version in VB.NET
2003 & tried to convert it without success.

Any help would be great as I haven't used C++ for over 7 years now

Thanks in advance,

Signature

Newbie Coder
(It's just a name)

Anders Eriksson - 07 Mar 2007 14:41 GMT
> C++.NET 2003 ONLY
>
[quoted text clipped - 14 lines]
> But of course that isn't what I am looking for. I wrote a version in VB.NET
> 2003 & tried to convert it without success.

I'm guessing that you are using VC++ UNMANAGED. the you use the
GetVersionEx() to get windows version.

e.g.

bool IsWindowsXP()
{
    OSVERSIONINFO osvi;
    bool bIsWindowsXPorLater;

    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx (&osvi);
    bIsWindowsXPorLater =
        ( (osvi.dwMajorVersion > 5) ||
        ( (osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1) ));

    return bIsWindowsXPorLater;
}

You find more info here:
http://msdn2.microsoft.com/en-us/library/ms724451.aspx

// Anders
Signature

English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!

Anders Eriksson - 07 Mar 2007 14:59 GMT
>> I need to check to see that the user is using Windows 2000 or later on
>> program startup. If not, to disable one radiobutton
[quoted text clipped - 12 lines]
>     return bIsWindowsXPorLater;
> }

Oops! I read your mail a bit fast... To check for 2000 and later you change
osvi.dwMinorVersion>=0

You might then want to change the function name ;-)

// Anders
Signature

English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!

Newbie Coder - 07 Mar 2007 20:06 GMT
Thank you for your replies Anders.

Actually Anders I am using managed code or at least I am using managed code
in my application.

So, surely I have to declare the structure, don't I?

Basically, I am using the DLLIMPORT Attribute so maybe I can declare the
GetVersionEx in that way. Is that correct?

Awaiting a reponse,

Signature

Newbie Coder
(It's just a name)

> >> I need to check to see that the user is using Windows 2000 or later on
> >> program startup. If not, to disable one radiobutton
[quoted text clipped - 19 lines]
>
> // Anders
Ben Voigt - 07 Mar 2007 22:27 GMT
> Thank you for your replies Anders.
>
[quoted text clipped - 6 lines]
> Basically, I am using the DLLIMPORT Attribute so maybe I can declare the
> GetVersionEx in that way. Is that correct?

From C++, you can just #include <windows.h> just like a native program.
Only C# has to mess with DllImport.

> Awaiting a reponse,
>
[quoted text clipped - 22 lines]
>>
>> // Anders
Willy Denoyette [MVP] - 07 Mar 2007 23:43 GMT
> Thank you for your replies Anders.
>
[quoted text clipped - 7 lines]
>
> Awaiting a reponse,

No need to call into native code, the FCL is your friend, take a look at the
System.Diagnostics namespace class OperatingSystem.

Willy.
Newbie Coder - 08 Mar 2007 11:01 GMT
This has now been resolved. Here's the code I used:

using namespace system;

bool Is2000OrLater()
{
 OperatingSystem* osInfo = Environment::OSVersion;
 PlatformID pID = osInfo->Platform;
 switch(pID)
 {
   case PlatformID::Win32NT:
    if (osInfo->Version->Major == 5 && osInfo->Version->Minor >= 0)
       return true;
 else
       return false;
   default:
    return false;
 }
}

Thanks for all your replies,

Signature

Newbie Coder
(It's just a name)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.