Selecting a Device (WIA)
When an application connects to a Windows Image Acquisition (WIA) hardware device, WIA creates an item tree (a hierarchical tree of IWiaItem or IWiaItem2 interfaces) that represents the device and its images, folders, and scanning beds. An application can select and connect to a device without user input, or it can display a dialog box that allows a user to select a device.
Selecting a Device Without the UI
Perform the following steps to select and connect to a WIA hardware device.
- Call CoCreateInstance to retrieve a pointer to the IWiaDevMgr or IWiaDevMgr2 interface.
- Use the IWiaDevMgr::EnumDeviceInfo method of the IWiaDevMgr or IWiaDevMgr2 interface to obtain a pointer to the IEnumWIA_DEV_INFO interface. For instructions on how to enumerate devices, see Enumerating System Devices.
- Use IEnumWIA_DEV_INFO interface to obtain IWiaPropertyStorage interface pointers for each WIA device enumerated.
- Use IWiaPropertyStorage interface to inspect the device information properties of each device and save the WIA_DIP_DEV_ID property from the desired device.
- Use the DeviceID property with the IWiaDevMgr::CreateDevice method in the IWiaDevMgr or IWiaDevMgr2 interface to create a WIA device object. The IWiaDevMgr::CreateDevice method provides the application with the pointer to the IWiaItem or IWiaItem2 interface of the root item of the specified device.
For an example of how to do this in an application, see Creating a Device in the tutorial section of this guide.
Selecting a Device With the UI
After retrieving a pointer to IWiaDevMgr, an application can allow a user to select a device by skipping the rest of the above steps and calling IWiaDevMgr::SelectDeviceDlg. The IWiaDevMgr::SelectDeviceDlg displays a dialog box in which the user can select a WIA device.
It is recommended that applications make device and image selection available through a menu item named From scanner on the File menu.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for