about the "#if (_WIN32_WINNT >= 0x0501)" in the system headers....

L

Lloyd Dupont

In my code I would like to use the constant (define in WinGdi.h)
CLEARTYPE_QUALITY
But that doesn't work!!
(it's for CreateFont(...))

A quick look at the header reveal that:
== WinGdi.h fragment ===
#if (_WIN32_WINNT >= 0x0500)
#define CLEARTYPE_QUALITY 5
#endif
===================

Now I wonder, how do I define _WIN32_WINNT ?
- should I just go into Project Properties => Configuration => C/C++ /
Preprocessor => Definition
and put some random value?

- beside how will this work?
generally speaking my product work on Windows 2000 & XP and this constant is
not a bit flag, it's a number (other constant are 1,2,3,4)

Any tips? advice? ideas? suggestion?
 
J

Jochen Kalmbach [MVP]

Hi Lloyd!
A quick look at the header reveal that:
== WinGdi.h fragment ===
#if (_WIN32_WINNT >= 0x0500)
#define CLEARTYPE_QUALITY 5
#endif
===================

Now I wonder, how do I define _WIN32_WINNT ?
- should I just go into Project Properties => Configuration => C/C++ /
Preprocessor => Definition
and put some random value?

It should not be random...
See: Using the Windows Headers
http://msdn.microsoft.com/library/en-us/winprog/winprog/using_the_windows_headers.asp


If you have a current PSDK, you should set "NTDDI_VERSION"
generally speaking my product work on Windows 2000 & XP and this constant is
not a bit flag, it's a number (other constant are 1,2,3,4)

The define
NTDDI_VERSION=NTDDI_WIN2K
in your project settings

Or (for older PSDKs):
_WIN32_WINNT=0x0500
WINVER=0x0500

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
E

Egbert Nierop \(MVP for IIS\)

Lloyd Dupont said:
In my code I would like to use the constant (define in WinGdi.h)
CLEARTYPE_QUALITY
But that doesn't work!!
(it's for CreateFont(...))

A quick look at the header reveal that:
== WinGdi.h fragment ===
#if (_WIN32_WINNT >= 0x0500)
#define CLEARTYPE_QUALITY 5
#endif
===================

Now I wonder, how do I define _WIN32_WINNT ?
- should I just go into Project Properties => Configuration => C/C++ /
Preprocessor => Definition
and put some random value?

surely not a random value.
- beside how will this work?
generally speaking my product work on Windows 2000 & XP and this constant
is not a bit flag, it's a number (other constant are 1,2,3,4)

Any tips? advice? ideas? suggestion?

#define _WIN32_WINNT 0x0501

in stdafx.h will do best.
 
G

Guest

Egbert Nierop (MVP for IIS) said:
#define _WIN32_WINNT 0x0501

in stdafx.h will do best.

Keep in mind that if you are defining _WIN32_WINNT to a specific value
because an API requires it, it is because that API requires at least that
version of Windows to run.

Therefore, if your product must work on Windows 2000, and you are using an
API that requires at least Windows XP (which is what setting _WIN32_WINNT to
0x0501 means), then you are going to have a problem later on when you try to
run your product on Windows 2000.

For your particular situation, ClearType wasn't introduced until WinXP.
Depending on what you are doing with ClearType, you may need to write code to
ascertain which version of Windows is running and to take action accordingly.

Sean
 
L

Lloyd Dupont

Thanks for addressing the second part of my question!
I though along those lines:
all these constants are just increasing number (1,2,3,4 and 5 for cleartype)
not only it should be available for windows 2000 in a service pack but,
hopefully, the function should gracefuly either of:
-use a known lower number
-use default DRAFT quality instead....


Anyway, any tip on how to write a simple test of the current OS?

thanks!
 
W

William DePalo [MVP VC++]

Lloyd Dupont said:
Anyway, any tip on how to write a simple test of the current OS?

The short answer to the question is to say that you call GetVersionEx().

But you have to understand that if you build an application so that it only
runs on 2K or better, and if someone tries to launch that binary on NT4 say
(a platform which should be retired IMO) that your application may not ever
get to the point of calling GetVersionEx().

An application will fail to load if it makes implicit reference to a
function in a DLL which is not present at load time.

Regards,
Will
 
B

Ben Voigt

William DePalo said:
The short answer to the question is to say that you call GetVersionEx().

But you have to understand that if you build an application so that it
only runs on 2K or better, and if someone tries to launch that binary on
NT4 say (a platform which should be retired IMO) that your application may
not ever get to the point of calling GetVersionEx().

An application will fail to load if it makes implicit reference to a
function in a DLL which is not present at load time.

If the DLL is not present, the application fails to load. If the DLL is
present but an older version so the function is missing, the application
loads and only fails if it tries to call that function, correct?
 
W

William DePalo [MVP VC++]

Ben Voigt said:
If the DLL is not present, the application fails to load. If the DLL is
present but an older version so the function is missing, the application
loads and only fails if it tries to call that function, correct?

No.

At least not if you link the DLL implicitly. If you do that, at runtime the
loader will display a message box which says something like this:

"The procedure entry point XXXX could not be located in dynamic link
library YYYY".

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top