-
October 2nd, 2009, 12:18 PM
#1
Determine Windows OS from #define
I have a device handler that was not working with Windows XP. It was fixed by a few #pragma statements ( #pragma inline_depth(0) ) around some areas of code. This fixed it for Windows XP, however....we just noticed that it broke it for Windows 2000.
Is there a simple #define I can check to wrap the pragmas that will determine if OS is Windows 2000 or XP.
Basically, I want something like,
Code:
#ifdef WINXP
#pragma inline_depth(0)
#endif
I'm googling, but not seeing something like that. I'm guessing there should be.
Will WINVER be sufficient? What are correct values?
According to this page,
0x500 should be value for Win2000,
and
0x501 for XP.
But those are minimum values.....so would I get screwed with some "in between values" perhaps?
Any help?
-
October 2nd, 2009, 01:10 PM
#2
Re: Determine Windows OS from #define
I just tried wrapping with:
Code:
#ifdef (WINVER > 0x500)
#pragma inline_depth(0)
#endif
I should know Monday morning if that worked or not.
-
October 2nd, 2009, 01:43 PM
#3
Re: Determine Windows OS from #define
Macros are used before compiling while the os version can be known only when the program is running...
Are you expecting that a program would know what os it will run on before it is not even compiled?
WINVER is what windows.h expects YOU to define. If there really are compatibiliy problem, seperate program into two versions.
Last edited by DreamShore; October 2nd, 2009 at 01:46 PM.
Nope
-
October 5th, 2009, 12:10 PM
#4
Re: Determine Windows OS from #define
What DreamShore said.
Essentially, you'd have to have different versions of your EXE for the different platforms you want to support. So, at install time, you can determine which exe to install.
Try taking the EXE you created by adding that #ifdef, and run it on a Win2K machine. It should still be broken.
Viggy
-
October 5th, 2009, 01:13 PM
#5
Re: Determine Windows OS from #define
Thanks for the tips/reminders.
I really want to avoid having two separate version of the EXE if possible.
I am now trying a solution like this (hopefully will get time to get on the testers in the next few hours). Do you think this will work?
Code:
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
// For SCR#185
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
// If GetVersionEx fails, nothing we can do. AFDX may fail
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
GetVersionEx ( (OSVERSIONINFO *) &osvi);
}
// check for WinXP, only call for winXP
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
{
this->ProcessActionXP();
}
else
{
this->ProcessAction2000();
}
The ProcessAction2000 and ProcessActionXP are in separate files.
-
October 5th, 2009, 02:28 PM
#6
Re: Determine Windows OS from #define
What about Vista? Windows 7?
Viggy
-
October 5th, 2009, 02:31 PM
#7
Re: Determine Windows OS from #define
Not a concern....this is an old legacy program that's being phased out. No chance it will be on Vista or 7. It will only be on the platforms its currently on.
Originally Posted by MrViggy
What about Vista? Windows 7?
Viggy
BTW....the above method appears to have worked!
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
|