|
-
September 29th, 2003, 08:11 AM
#1
Conditional compilation by Windows version
I want to conditionally compile sections of code if the Windows version is not Windows 95.
Am I correct in assuming that I can't use ::GetVersionEx?
Am I correct that #if (WINVER > 0x400) will work but it will also exclude for NT 4?
How do you suggest I do this?
-
September 29th, 2003, 08:23 AM
#2
Am I correct in assuming that I can't use ::GetVersionEx?
Yes, you're correct. Function/method calls are not evaluated at compile time.
I'm not sure about the various #defines for WINVER. There may be a header someplace with that info.
You realize that a conditional compile will only be effective for the building of the application i.e. if you build it on a win 95 or XP machine -- if you build on XP (etc..) it will still be the same application when you move it to 95...
Last edited by bytz; September 29th, 2003 at 08:26 AM.
bytz
--This signature left intentionally blank--
-
September 29th, 2003, 08:31 AM
#3
Re: Conditional compilation by Windows version
Originally posted by Bob H
I want to conditionally compile sections of code if the Windows version is not Windows 95.
Just think again about what you're asking here... Got a little confused about compile time vs. run time?
-
September 29th, 2003, 08:38 AM
#4
These are the winver values that I could find
** WINVER < 0x400 = Windows NT 3.5, Windows NT 3.51
** WINVER = 0x400 = Windows 95, Windows NT SUR (default)
** WINVER > 0x400 = Windows NT SUR enhancements
WINVER = 0x030a (NT 3.5?)
WINVER = 0x0500 (XP/2000?)
Good luck
bytz
--This signature left intentionally blank--
-
September 29th, 2003, 08:40 AM
#5
I am getting runtime errors when the application runs on Window 95 machines like "... exe file is linked to missing export USER32.DLL: Track Mouse event".
I believe I can solve this by excluding certain code at compile time. I added an Office XP menu system which uses trackmouseevent. By excluding includes to this code and other code references to the office xp menu system, it should revert to the regular windows menu system and the error messages should go away.
------------------
I read the posts above again and thought a bit. You are right. This won't work because this method is tied to the machine I am compiling on.
Last edited by Bob H; September 29th, 2003 at 08:43 AM.
-
September 29th, 2003, 11:56 AM
#6
No... yes, well, actually you're right and wrong. Yes, what is included in the application and how it works is determined by the compile machine. No, if you want to make it work on different machines, you don't want to use conditional compliation.
For features that don't work well on "back" versions of Windows, like 95 with no service packs/upgrades, you'll need to add code that checks the version of windows and executes the appropiate code, like:
// PSEUDO CODE!!!
if (version >= 98)
do one thing
else
do other thing
Note: this is conditional execution not conditional compliation.
bytz
--This signature left intentionally blank--
-
September 29th, 2003, 11:58 AM
#7
There should be several threads and sample code to detect and interput the version information for windows. A sample code for drawing gradients illustrates a simple use for this.
bytz
--This signature left intentionally blank--
-
September 29th, 2003, 12:18 PM
#8
I know how to do that. Thanks.
I got this Office XP menu code off CodeProject. I have posted on the forum associated with the code if this approach of excluding calls to the code at runtime will solve the problem. There are 8 different calls to the code so I will probably wait for an answer before plunging in.
-
September 29th, 2003, 12:19 PM
#9
Originally posted by bytz
These are the winver values that I could find
** WINVER < 0x400 = Windows NT 3.5, Windows NT 3.51
** WINVER = 0x400 = Windows 95, Windows NT SUR (default)
** WINVER > 0x400 = Windows NT SUR enhancements
WINVER = 0x030a (NT 3.5?)
WINVER = 0x0500 (XP/2000?)
Good luck
MSDN should have a table if you just look for WINVER
-
September 29th, 2003, 12:35 PM
#10
In such situations where there is a runtime decision, I sometimes do this.
1. GetVersion or GetVersionEx...
2. if Platform 1,
API1
else
API2.
Here, I do not use LoadLibrary, GetProc etc... but I use the APIs themselves, supported or unsupported. But these DLLs, I force to delay load..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|