In order to really hire the scanner in WinForms with C# in artistic Studio, we will make use of the WIA API.

In order to really hire the scanner in WinForms with C# in artistic Studio, we will make use of the WIA API.

House windows graphics purchase (WIA) occasionally referred to as Screens imagery Architecture) was a Microsoft driver version and product programs program (API) for Microsoft Screens 2000 and later os’s that permits design software to talk with imaging components such as for instance scanners, cameras and virtual Video-equipment.

WIA tends to make an easy task to software designers, product makers, and scanner people who need to have interaction with imaging devices.

The API poised reveals imaging applications to still design acquiring equipment efficiency by giving support for:

  • Enumeration of available picture exchange equipment (put in scanners in computers running Windows).
  • Produce connectivity to a number of units concurrently.
  • instabang android app

  • Querying properties of accessories in an ordinary and expandable way.
  • Getting tool records with regular and high performance move systems.
  • Preserving image hotels across reports exchanges.
  • Alerts of unit updates and scan occasion care.

In this posting, you’ll find out a way to control an image scanner through WIA with C#.


  • Aesthetic Studio >= 2007 (we’re going to need Visual school group)
  • a set up and useful scanner

We should start out !

1. Add some the WIA resource

Generate a new WinForms job because of the current .NET platform adaptation (or an old C# job). Consequently go on to list the Microsoft windows graphics order COM component straight from visual school. An element item Model (COM) is a platform-independent, dispensed, object-oriented method for starting binary computer software factors that can connect. .NET factors can dub and connect with COM products.

Look at the choice explorer based in the best best spot of aesthetic facility and manage best click on any project, then click on include > mention.

From inside the emergent window, choose the COM solution during the put menu and locate the Microsoft Microsoft windows picture acquiring collection v2.0 and then click on acceptable.

When you touch okay, the referral will likely be included with any project. So now you have to poised the Embed Interop sort home regarding the WIA element of False . With graphic Studio go to the answer Explorer and choose any project, after that inside project select recommendations from your pine viewpoint element and find WIA. Choose the WIA guide and check out the implant Interop kinds alternative inside Properties section and place this worth to fake :

So you will be able to use WIA within your plan.

2. list scanner instruments

To listing the machines, you should retrieve checklist within the DevicesManager target of WIA. As 1st step, you must transfer the WIA aspect in your rule on top of your own school:

Consequently only iterate on the tool supervisor to write the devices:

The belongings target keeps different homes like identification document , interface , Manufacturer and Type , look at the MSDN page regarding the WIA appliance info classroom for more information.

3. making use of a device to scan

To truly save the scanned looks you need to import here sorts:

Then your reason to utilize the scanner certainly is the sticking with:

  1. Retrieve a DeviceInfo instance regarding the scanner that you like to use.
  2. Get connected to the scanner making use of the DeviceInfo circumstances.
  3. Find scanner through factor with index 1 within the equipment homes making use of link instance.
  4. Make use of the send method for the chosen scanner and provide as very first assertion the result format associated with the scanned image.
  5. Save the came back impression information to a file.

The earlier reasoning was used making use of preceding signal. We will select the 1st available scanner on the program and we also’ll go through the past formula:

Practise to consider the scanner right after which operate the remainder of rule to start out with the checking procedure can be somewhat complicated unless you take care of it effectively. We recommend your eg to include an email list field piece to your kind and append an innovative new items that shows the expression and also the DeviceInfos object too (you will see an instance at the end of the content).

If you decide to test that, the signal is guaranteed to work while the scanner begins, however the impression shall be incompleted on most on the readers. That is because most people don’t specify all usual residential properties of scanner, that you’ll try to emerge these action.

4. Changing WIA residential properties

You will find several modifiable land of WIA simillar to the scanning thickness and peak, the colour form etcetera. To put this land, we have to collect the home or property with the WIA.Properties type and then poised the new importance. Importance the necessary type as initial:

Below means AdjustScannerSettings will established some basic hotels through the associate function SetWIAProperty , for it to be just work at lowest in the majority of associated with checking devices. Observe that you should incorporate a scanner product as basic parameter within the AdjustScannerSettings (the scanner picked and allotted to a variable by the component with directory 1 in the objects land with the relationship incidences) process as well more criteria that are recognized through the work.


Bear in mind that WIA has a lot of attributes constants you could modify understanding that might or maybe not available on various scanning machines (e.g to change the outside determination take advantage of continuous 6147 ), investigate correct MSDN web page for details.

This worthy of saying once more, definitely your decision the modification with the residential properties, but currently one an uncomplicated strategy to tailor them with the SetWIAProperty method.

Finally, to begin the skim effectively you only need to execute the AdjustScannerSettings strategy until the initialization of scanner (combining the 3 and 4):

5. Catching conditions

WIA operates options can place exceptions that could be identified through oversight rules. The list of mistake limitations are available in the documentation of WIA when you look at the MSDN internet site right here. To control the problems of WIA, discover the COMException subject. Make the time to transfer before the InteropServices kind:

Immediately after which cover the laws that utilizes WIA inside a try-catch argument. You may establish the mistake because of the ErrorCode assets regarding the exemption, keep in mind to transform they to the uint counsel determine contrast they making use of the mistake requirements of the table in MSDN.

Leave a Reply

Your email address will not be published. Required fields are marked *