I used RegisterDeviceNotification
API in my code. It is not working (getting linker errror), if I'm not using #define WINVER 0x501
.
1) When I look into window Winuser.h
, RegisterDeviceNotificationA
is defined under #if(WINVER >= 0x0500)
. What is the reason for this?
2) To make RegisterDeviceNotificationA
work I declared all the declarations in my own .h file without #if(WINVER >= 0x0500)
. Is this right way?
3) My another question here is there any problem in declaring RegisterDeviceNotificationA
without winver? what is the use of Winver? Please explain me in detail.
The primary purpose of definitions like WINVER
is to compile old code with recent compilers.
If you are writing new code, you need to define this variable and maybe several others in your cpp file or in your project file. The value is the version of Windows that you are targeting. This is how Microsoft designed it.
It is extremely bad practice to duplicate system definitions into your code.