I upgraded to Qt 5.5 and RegisterDeviceNotificationcall started to generate a link error and project doesn't built. It still builds with Qt 5.4 and I am using VS2010 compiler in both cases.
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
MSG * msg = static_cast< MSG * > (message);
int msgType = msg->message;
if(msgType == WM_PAINT)
{
if(!msgp) //Only the first WM_PAINT
{
GUID InterfaceClassGuid = HID_CLASSGUID;
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) );
NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
NotificationFilter.dbcc_classguid = InterfaceClassGuid;
HWND hw = (HWND) this->effectiveWinId(); //Main window handle
HDEVNOTIFY hDevNotify = RegisterDeviceNotification(hw,&NotificationFilter, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); //DEVICE_NOTIFY_WINDOW_HANDLE);
msgp = true;
}
}
// i have more code here but the link error occurs in the above
}
I did include <windows.h> and <WinUser.h> but that didn't fix the link error.
The link error is:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol __imp__RegisterDeviceNotificationW@12 referenced in function "private: virtual bool __thiscall MainWindow::nativeEvent(class QByteArray const &,void *,long *)" (?nativeEvent@MainWindow@@EAE_NABVQByteArray@@PAXPAJ@Z)
I tried to include modules in .pro files from here but none has made any difference.