由於要響應設備的插拔,所有要註冊設備的事件通知,用到'HDEVNOTIFY' 等的時侯,編譯出現了莫名奇妙的錯誤:
error C2146: syntax error : missing ';' before identifier 'm_hDevNotify'
error C2501: 'HDEVNOTIFY' : missing storage-class or type specifiers
error C2065: 'UnregisterDeviceNotification' : undeclared identifier
error C2065: 'DEV_BROADCAST_DEVICEINTERFACE' : undeclared identifier
error C2065: 'DEVICE_NOTIFY_WINDOW_HANDLE' : undeclared identifier
後在MSDN上找到答案,只要在stdafx.h的開始定義WINVER大於0x0500即可:
例如: #define WINVER 0x0501