i'm deverloping a product .... in a c++ code page I declare import "pkcs11.h" and i using RegisterDeviceNotification function to registers the device or type of device for which a window will receive notifications . but it all way Fail . #include <wincrypt.h> #include <pkcs11.h> #pragma comment (lib,"User32.lib") ...... ....... ....... //register the usb events for this window HDEVNOTIFY hDevNotify; DEV_BROADCAST_DEVICEINTERFACE DevDesc; DevDesc.dbcc_size = sizeof(DevDesc); DevDesc.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; DevDesc.dbcc_classguid = GUID_CLASS_USB_DEVICE; hDevNotify=RegisterDeviceNotification(this->m_hWnd, &DevDesc, DEVICE_NOTIFY_WINDOW_HANDLE); if( !hDevNotify ) { //MessageBox("Can't detect register device notification"+ErrorToString(,"USB",MB_OK); */ MessageBox(errorMess,"USB",MB_OK); }
the problem is when i declare [import "pkcs11.h" ] then hDevNotify allway is NULL(fail) . when i don't declare [import "pkcs11.h" ] then RegisterDeviceNotification is complete now i want use pkcs11.h and RegisterDeviceNotification is complete . please show me how to do it? thanks alot!
oh !! i have found this error . the reason is a duplicate fuction in pkcs11.h and windows.h or Winuser.h (I guess that , i don't know exactly ) . I declare a line code [ #pragma once] at top of page to fix this error thank !