473,372 Members | 1,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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

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,

--
Newbie Coder
(It's just a name)
Mar 7 '07 #1
6 5037
On Wed, 7 Mar 2007 12:46:42 -0000, Newbie Coder wrote:
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.
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
--
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!
Mar 7 '07 #2
On Wed, 7 Mar 2007 15:41:10 +0100, Anders Eriksson wrote:
On Wed, 7 Mar 2007 12:46:42 -0000, Newbie Coder wrote:
>I need to check to see that the user is using Windows 2000 or later on
program startup. If not, to disable one radiobutton

bool IsWindowsXP()
{
OSVERSIONINFO osvi;
bool bIsWindowsXPorLater;

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

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
--
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!
Mar 7 '07 #3
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,

--
Newbie Coder
(It's just a name)
"Anders Eriksson" <an*****@gmail.comwrote in message
news:bj**************@ostling.com...
On Wed, 7 Mar 2007 15:41:10 +0100, Anders Eriksson wrote:
On Wed, 7 Mar 2007 12:46:42 -0000, Newbie Coder wrote:
I need to check to see that the user is using Windows 2000 or later on
program startup. If not, to disable one radiobutton
bool IsWindowsXP()
{
OSVERSIONINFO osvi;
bool bIsWindowsXPorLater;

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

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
--
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!

Mar 7 '07 #4

"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:Ov*************@TK2MSFTNGP04.phx.gbl...
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?
From C++, you can just #include <windows.hjust like a native program.
Only C# has to mess with DllImport.
>
Awaiting a reponse,

--
Newbie Coder
(It's just a name)
"Anders Eriksson" <an*****@gmail.comwrote in message
news:bj**************@ostling.com...
>On Wed, 7 Mar 2007 15:41:10 +0100, Anders Eriksson wrote:
On Wed, 7 Mar 2007 12:46:42 -0000, Newbie Coder wrote:

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

bool IsWindowsXP()
{
OSVERSIONINFO osvi;
bool bIsWindowsXPorLater;

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

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
--
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!


Mar 7 '07 #5
"Newbie Coder" <ne*********@spammeplease.comwrote in message
news:Ov*************@TK2MSFTNGP04.phx.gbl...
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,
No need to call into native code, the FCL is your friend, take a look at the
System.Diagnostics namespace class OperatingSystem.

Willy.

Mar 7 '07 #6
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,

--
Newbie Coder
(It's just a name)
Mar 8 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
2
by: Christopher W. Douglas | last post by:
I have an MSDN subscription, and have all versions of Windows Server 2003 available. I have been programming in Visual Studio .NET 2002 in Windows XP and 2000, and I am setting up a new machine...
2
by: FrodoBaggins | last post by:
Dear Team, I am running Visual Studio 2003 Version 7.1.3088 on Windows Server 2003. I have written a C# application that must write to the event log. When it attempts to write to the event log,...
10
by: ThunderMusic | last post by:
Hi, How can I get if the Windows running is a server version? Is there a property somewhere that can tell me if the Windows version is a server edition (including server, advanced server, web...
12
by: Onega | last post by:
Hi I create a simple win32 project (VC2003, windows2003(English) , and do simple paint in WM_PAINT message, when the project use multi-character set, it is OK. but when I change to UNICODE,...
7
by: lvpaul | last post by:
Hallo ! I am using IIS-Windows-Authentication in my intranet (web.config <authentication mode="Windows" /> <identity impersonate="true" /> How can I get the users (client) IP-Address ? I...
4
by: bob lambert | last post by:
Help I am trying to deploy to another pc a vb.net std 2002 windows form application. I am confused. I created a project - windows form I built form, compiled and debugged. I created a...
6
by: Alan Silver | last post by:
Hello, Sorry if this is slightly OT, but I reckon there would be folks here who would know... I have a Windows 2003 Server box, SP4 and .NET 2.0 installed. Trouble is that it also has .NET...
3
by: Jim Richards | last post by:
When I print out the Help files for an error, it says: "1. Make sure that the Web server computer is running a server version of Windows 2000, Windows XP, or Windows Server 2003. At this point,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.