The windows version about the driver. A problem at coding and compile.

I my driver’s source code, I want some code build in “Win XP Checked Build
Environment” and some build in “Win 2K Checked Build Environment”. How
should I do?
Fox example:
If I use “Win XP Checked Build Environment”, I want a = b + c;
If I use “Win 2K Checked Build Environment”, I want a = b - c;

Use the code below?
#ifdef _WIN32_WINNT
a = b + c;
#else
a = b - c;
#endif
What’s the correct coding?

to check for Win XP or Win 2K you can use the NTDDI constants & macros defined in sdkddkver.h to check the defined value of NTDDI_VERSION; for example, (OSVER(NTDDI_VERSION) > NTDDI_WIN2K) shall mean any OS after Win2K;

another option (a runtime one) would be to use the RtlGetVersion function; to obtain its adress dynamically, you can use MmGetSystemRoutineAddress(&fnName); where fnName is a UNICODE_STRING initialized to L"RtlGetVersion";

to check if you are in a debug / checked build or not, you can check if the DBG macro is defined or not; however I don’t know (but there shall be!) a method to detect thin runtinme;

hope it is usefull,

Alex

Thanks very much.

дÈëÏûÏ¢ÐÂÎÅ:xxxxx@ntfsd…
> to check for Win XP or Win 2K you can use the NTDDI constants & macros
> defined in sdkddkver.h to check the defined value of NTDDI_VERSION; for
> example, (OSVER(NTDDI_VERSION) > NTDDI_WIN2K) shall mean any OS after
> Win2K;
>
> another option (a runtime one) would be to use the RtlGetVersion function;
> to obtain its adress dynamically, you can use
> MmGetSystemRoutineAddress(&fnName); where fnName is a UNICODE_STRING
> initialized to L"RtlGetVersion";
>
> to check if you are in a debug / checked build or not, you can check if
> the DBG macro is defined or not; however I don’t know (but there shall
> be!) a method to detect thin runtinme;
>
> hope it is usefull,
>
> Alex
>