473,839 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5061
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 bIsWindowsXPorL ater;

osvi.dwOSVersio nInfoSize = sizeof(OSVERSIO NINFO);
GetVersionEx (&osvi);
bIsWindowsXPorL ater =
( (osvi.dwMajorVe rsion 5) ||
( (osvi.dwMajorVe rsion == 5) && (osvi.dwMinorVe rsion >= 1) ));

return bIsWindowsXPorL ater;
}

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 bIsWindowsXPorL ater;

osvi.dwOSVersio nInfoSize = sizeof(OSVERSIO NINFO);
GetVersionEx (&osvi);
bIsWindowsXPorL ater =
( (osvi.dwMajorVe rsion 5) ||
( (osvi.dwMajorVe rsion == 5) && (osvi.dwMinorVe rsion >= 1) ));

return bIsWindowsXPorL ater;
}
Oops! I read your mail a bit fast... To check for 2000 and later you change
osvi.dwMinorVer sion>=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 bIsWindowsXPorL ater;

osvi.dwOSVersio nInfoSize = sizeof(OSVERSIO NINFO);
GetVersionEx (&osvi);
bIsWindowsXPorL ater =
( (osvi.dwMajorVe rsion 5) ||
( (osvi.dwMajorVe rsion == 5) && (osvi.dwMinorVe rsion >= 1) ));

return bIsWindowsXPorL ater;
}

Oops! I read your mail a bit fast... To check for 2000 and later you
change
osvi.dwMinorVer sion>=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*********@sp ammeplease.comw rote in message
news:Ov******** *****@TK2MSFTNG P04.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.hjus t 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 bIsWindowsXPorL ater;

osvi.dwOSVersio nInfoSize = sizeof(OSVERSIO NINFO);
GetVersionEx (&osvi);
bIsWindowsXPorL ater =
( (osvi.dwMajorVe rsion 5) ||
( (osvi.dwMajorVe rsion == 5) && (osvi.dwMinorVe rsion >= 1) ));

return bIsWindowsXPorL ater;
}

Oops! I read your mail a bit fast... To check for 2000 and later you
change
>osvi.dwMinorVe rsion>=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*********@sp ammeplease.comw rote in message
news:Ov******** *****@TK2MSFTNG P04.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.Diagnost ics 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::OS Version;
PlatformID pID = osInfo->Platform;
switch(pID)
{
case PlatformID::Win 32NT:
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
4465
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 I am currently doing: When I run sqlservr.exe I see the following: 2003-12-19 15:51:28.20 server Microsoft SQL Server 2000 - 8.00.760 (Intel X8 6)
2
15237
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 Personal disk from the SQL Server 2000 Enterprise kit as this is reported here on the MSDN web site to be the version that is supported on Windows XP. In fact so many of you kind people confess to having succeeded in doing it. I have tried...
2
2200
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 with .NET 2003 for new projects. My question is, which version of Windows Server 2003 (Standard, Enterprise, Web) is best for .NET development? I am only using the computer for development, I won't be running any of my applications from it. ...
2
13521
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, however, I get the following message on the browser shown below in bold text: Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required...
10
3510
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 server, etc) or just a workstation (if it's not a workstation, then it's a server). My app must verifies that for security reasons. It should work from at least windows 2000 (Windows 98 and ME, would appreciated to, but if it's not possible, I'll...
12
3903
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, some Chinese characters are illegible( I see sizeof(TCHAR)=2 being displayed). Your idea is welcome. case WM_PAINT: hdc = BeginPaint(hWnd, &ps);
7
3221
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 think the username can be read with user.identity.name.
4
7092
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 deployment project (myproj installer) I added my windows app to the installer under myproj installer properties, I set bootstrapper
6
4189
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 versions 1.0 and 1.1 installed. I would just ignore them, but occasionally one or two of the web sites on the machine seem to set themselves to the wrong version, and this causes errors. I have no idea why or how this happens, but it does happen...
3
1711
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, I do not know if my PC is acceptable for programming Web Applications. Just exactly what does "a server version of Windows XP" mean? I have Windows XP Professional w/SP2 and I have IIs and Front Page Extensions installed using the "Add/Remove...
0
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10908
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10295
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7829
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7018
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.