Windows Dev Center

Registering for Events

The following example uses the Windows Image Acquisition (WIA) 1.0 IWiaDevMgr::RegisterEventCallbackCLSID method to register for notification when any Windows Image Acquisition (WIA) device is connected to the system. Applications can also use WIA 1.0 IWiaDevMgr::RegisterEventCallbackInterface and WIA 1.0 IWiaDevMgr::RegisterEventCallbackProgram to register for events. With Windows Vista and later, you can use the Windows Image Acquisition (WIA) 2.0 IWiaDevMgr2::RegisterEventCallbackCLSID, IWiaDevMgr2::RegisterEventCallbackInterface, or IWiaDevMgr2::RegisterEventCallbackProgram methods to register for events.

It is assumed that the example is taken from an application that is registered as a Component Object Model (COM) out-of-process server object.

The call to IWiaDevMgr::RegisterEventCallbackCLSID (or IWiaDevMgr2::RegisterEventCallbackCLSID) is as follows:



    pWiaDevMgr->RegisterEventCallbackCLSID( WIA_REGISTER_EVENT_CALLBACK,
                                            NULL,
                                            WIA_EVENT_DEVICE_CONNECTED,
                                            pCLSID,
                                            bstrName,
                                            bstrDescription,
                                            bstrIcon
                                            );


In the previous code, pWiaDevMgr is a valid pointer to the IWiaDevMgr (or IWiaDevMgr2) interface, WIA_REGISTER_EVENT_CALLBACK is a constant that specifies that this call is to register for the event as opposed to unregistering for the event, WIA_EVENT_DEVICE_CONNECTED is a constant that specifies that the application is registering to be notified whenever a device is connected to the user's computer, pCLSID is a pointer to the registered CLSID of the application, bstrName is the name of the application, bstrDescription is a text description of the application, and bstrIcon is the name of an image file to be used for the icon for the application registering for the event.

The application must then implement the IWiaEventCallback::ImageEventCallback method, which is called whenever an event occurs for which the application is registered.

An application can use the IWiaItem::EnumRegisterEventInfo (or IWiaItem2::EnumRegisterEventInfo) method to enumerate the information about events for which it is registered.

 

 

Community Additions

ADD
Show:
© 2015 Microsoft