[Qt-interest] `DEV_BROADCAST_DEVICEINTERFACE' was not declared in this scope
Liam Staskawicz
lstask at gmail.com
Wed Sep 2 16:33:04 CEST 2009
I remember seeing this, and tracking it down as being related to the
WINVER symbol not behaving as expected in mingw - on an XP machine,
WINVER was not set to what I expected when I looked it up in the doc
(can't remember offhand what it was supposed to be, and what I
actually observed). So even though dbt.h is found, it doesn't end up
including the appropriate symbols and headers because of the version
mismatch. I hacked around this (not in the nicest way) by redefining
WINVER in my .pro file.
If anybody has a cleaner solution to this, I'd sure love to hear it!
Liam
On Sep 1, 2009, at 10:38 AM, Girish Ramakrishnan wrote:
> http://msdn.microsoft.com/en-us/library/aa363244(VS.85).aspx suggests
> that you should include dbt.h. Have you tried that? Or are you saying
> that dbt.h is not a part of MinGW?
>
> Girish
>
> Huseyin Kozan wrote:
>> 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
>> ------------------------------------------------------------------------------------------------------------------------------------------------------
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list