Computers running windows looks exchange (WIA) sometimes often known as Microsoft windows imagery buildings) happens to be a Microsoft driver version and product programs program (API) for Microsoft Computers running windows 2000 and soon after operating systems that permits images applications to talk with imaging components for example readers, digicams and handheld Video-equipment.

WIA helps make simple software programmers, tool makers, and scanner owners who require to interact with imaging hardware.

The API established reveals imaging methods to still picture purchase electronics functions by providing support for:

  • Enumeration of accessible looks acquire machines (installed scanners in windowpanes).
  • Creating connectivity to multiple gadgets concurrently.
  • Querying properties of systems in a normal and expandable style.
  • Obtaining unit information through the help of regular and high performing transfer components.
  • Having picture belongings across information transactions.
  • Notification of device level and scan function control.

In this specific article, you’ll learn suggestions adjust an image scanner through WIA with C#.


  • Visual workplace >= 2007 (we will incorporate Visual business neighborhood)
  • a set up and well-designed scanner

Let us get started !

1. combine the WIA mention

Build a new WinForms venture using last .NET structure version (or a well used C# undertaking). Subsequently go on to list the screens impression purchase COM part straight from optical studio. A Component target type (COM) try a platform-independent, dispensed, object-oriented technique for starting digital tool products that may connect. .NET hardware can label and connect with COM components.

Go directly to the solution explorer based in the best best corner of Visual school and do correct check out any project, then click include > mention.

Within the emergent window, choose the COM selection from inside the remaining menu and investigate the Microsoft computers running Windows Image acquiring selection v2.0 and then click on okay.

When you finally select alright, the address shall be put into any project. You now have to poised the Embed Interop kinds assets associated with WIA aspect of fake . With aesthetic business attend the option Explorer and choose assembling your project, next in your undertaking click on mention from the forest point of view aspect and research WIA. Choose the WIA reference to see the Embed Interop sorts option for the hotels section and set this importance to fake :

So you can utilize WIA in your venture.

2. detailing scanner systems

To listing the gadgets, you should retrieve checklist from DevicesManager target of WIA. As action, you must import the WIA component in your signal towards the top of your lessons:

Consequently only iterate across system administrator to list the instruments:

The characteristics thing provides other characteristics like identification , harbor , maker and Type , go to the MSDN web page with regards to the WIA tool information class find out more about.

3. utilizing a device to scan

Just to save the scanned image it is advisable to transfer here type:

Then this logic to make use of the scanner certainly is the next:

  1. Collect a DeviceInfo case regarding the scanner that you’d like to utilize.
  2. Hook up to the scanner by using the DeviceInfo example.
  3. Find scanner through feature with directory 1 within gear land on your connections circumstances.
  4. Take advantage of transport way of the chose scanner and offer as 1st assertion the output format belonging to the scanned picture.
  5. Save the came back graphics information to a file.

The prior logic try executed making use of the next rule. We’re going to choose 1st offered scanner from the method and in addition we’ll observe the preceding algorithmic rule:

The process to pick out the scanner thereafter make use of rest of laws to begin the checking system could be a little complicated unless you handle it properly. We recommend a person like to add an email list container items to your type and append a brand new item that shows the name and the DeviceInfos object way too (you might find a sample to the end of your article).

In the event you test it, the laws is going to work and also the scanner will start, but the image shall be incompleted of many for the scanners. That is because we did not ready many of the typical hotels of scanner, that you find out how to set-in here move.

4. Altering WIA hotels

There are some modifiable land of WIA similar to the scanning distance and top, the color form etc. To establish this homes, we need to access the property belonging to the WIA.Properties classroom immediately after which set the new importance. Importance the needed sorts as first:

The below process AdjustScannerSettings will adjust some fundamental belongings by the assistant features SetWIAProperty , to really make it work on lowest generally in most belonging to the checking systems. Observe that it is advisable to offer a scanner product as first factor for the AdjustScannerSettings (the scanner selected and assigned to a variable with the component with index 1 in the objects residential property by using the association example) strategy plus the additional guidelines which happen to be recorded from inside the purpose.


Remember that WIA provides extensive hotels constants that one could adjust hence might or maybe not on various checking products (example to modify the outside resolution make use of constant 6147 ), read the next MSDN web page for more information.

It worthy of saying once again, which up to you the customization from the hotels, but we offer your an easy approach to individualize using the SetWIAProperty technique.

Ultimately, to start the skim effectively you just need to perform the AdjustScannerSettings means before the initialization belonging to the scanner (mixing the step three and 4):

5. Catching exceptions

WIA operates means can throw exclusions that can be discovered through mistakes limitations. The roster of problem regulations are located in the documentation of WIA into the MSDN web site below. To deal with the problems of WIA, discover the COMException thing. Don’t forget to transfer formerly the InteropServices kinds:

Following put the signal that uses WIA inside a try-catch report. You can actually recognize the problem with the ErrorCode house regarding the exemption, but bear in mind to convert it to the uint description with a purpose to compare they employing the error programs of dinner table in MSDN.


About the Author: