[Qt-interest] `DEV_BROADCAST_DEVICEINTERFACE' was not declared in this scope

Huseyin Kozan huseyinkozan at gmail.com
Mon Aug 31 13:30:56 CEST 2009


Hello,

I searched the mingw list about the error in the subject but I
couldn't find anything.
Also I have searched in google and found this :
http://stackoverflow.com/questions/852752/how-to-know-when-a-new-usb-storage-device-is-connected-in-qt

My original code was working with VS 2008.
After trying with Qt Creator (with mingw), I got the same error in above post.


Huseyin




This is the function that registers the device notifications :
-------------------------------------------------------------------------------------
#include <windows.h>      // from C:\Qt\2009.03\mingw\include\windows.h
#include <Dbt.h>             // from C:\Qt\2009.03\mingw\include\dbt.h
// ...other header files
// ...other functions
void MainWindow::RegisterForDeviceNotifications(void)
{
       DEV_BROADCAST_DEVICEINTERFACE DevBroadcastDeviceInterface = {0};
       HDEVNOTIFY DeviceNotificationHandle;
       DevBroadcastDeviceInterface.dbcc_size =
sizeof(DevBroadcastDeviceInterface);
       DevBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
       DevBroadcastDeviceInterface.dbcc_classguid = GetHidGuid();
       DeviceNotificationHandle = RegisterDeviceNotification(winId(),
&DevBroadcastDeviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE);
}


And this is the error codes after compiling:
----------------------------------------------------------------
MainWindow.cpp: In member function `void
MainWindow::RegisterForDeviceNotifications()':
MainWindow.cpp:2073: error: `DEV_BROADCAST_DEVICEINTERFACE' was not
declared in this scope
MainWindow.cpp:2073: error: expected `;' before "DevBroadcastDeviceInterface"
MainWindow.cpp:2076: error: `DevBroadcastDeviceInterface' was not
declared in this scope
MainWindow.cpp:2077: error: `DBT_DEVTYP_DEVICEINTERFACE' was not
declared in this scope
MainWindow.cpp:2081: error: `DEVICE_NOTIFY_WINDOW_HANDLE' was not
declared in this scope
MainWindow.cpp:2081: error: `RegisterDeviceNotificationW' was not
declared in this scope
------------------------------------------------------------------------------------------------------------------------------------------------------




More information about the Qt-interest-old mailing list