←Select platform

IsAvailable Method

Summary

Determines which version of the WIA source is installed.

Syntax

C#
VB
C++
public static bool IsAvailable(  
   Leadtools.Wia.WiaVersion version 
) 
Public Shared Function IsAvailable( _ 
   ByVal version As Leadtools.Wia.WiaVersion _ 
) As Boolean 
public: 
static bool IsAvailable(  
   Leadtools.Wia.WiaVersion version 
) 

Parameters

version
The WIA version to be used. Possible values are:

Value

Meaning

WiaVersion.Version1 Use WIA version 1.0.
WiaVersion.Version2 Use WIA version 2.0.

Return Value

true if at least one WIA source of the specified version is installed, false if no WIA source is installed that supports the specified WIA version.

Remarks

Use this method to enable or disable WIA menu items.

Example

C#
VB
Imports Leadtools 
      Imports Leadtools.Codecs 
      Imports Leadtools.Wia 
 
      <TestMethod()> _ 
#If Not LEADTOOLS_V19_OR_LATER Then 
      Public Sub IsAvailableExample(ByVal parent As IWin32Window) 
#Else 
      Public Sub IsAvailableExample(ByVal parent As IntPtr) 
#End If ' #If LEADTOOLS_V19_OR_LATER Then 
         If (Not WiaSession.IsAvailable(WiaVersion.Version1)) Then 
            MessageBox.Show("WIA version 1.0 not installed.") 
            Return 
         End If 
         Dim session As WiaSession = New WiaSession() 
         session.Startup(WiaVersion.Version1) 
 
         Dim res As DialogResult = session.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault) 
         If res <> DialogResult.OK Then 
            MessageBox.Show("Error selecting WIA device.") 
            session.Shutdown() 
            Return 
         End If 
 
         ' Initialize and fill the required fields from the WiaAcquireOptions structure 
         Dim wiaAcquireOptions As WiaAcquireOptions = wiaAcquireOptions.Empty 
         wiaAcquireOptions.MemoryBufferSize = 32 * 1024 
         wiaAcquireOptions.DoubleBuffer = True 
         session.AcquireOptions = wiaAcquireOptions 
 
         AddHandler session.AcquireEvent, AddressOf session_AcquireEvent 
 
         session.Acquire(parent, Nothing, WiaAcquireFlags.ShowUserInterface Or WiaAcquireFlags.UseCommonUI) 
 
         RemoveHandler session.AcquireEvent, AddressOf session_AcquireEvent 
         session.Shutdown() 
      End Sub 
 
      Public Sub session_AcquireEvent(ByVal sender As Object, ByVal e As WiaAcquireEventArgs) 
         Application.DoEvents() 
 
         If (e.Flags And WiaAcquiredPageFlags.StartOfPage) = WiaAcquiredPageFlags.StartOfPage Then 
            Console.WriteLine("Beginning of data transfer.") 
         ElseIf (e.Flags And WiaAcquiredPageFlags.EndOfPage) = WiaAcquiredPageFlags.EndOfPage Then 
            Console.WriteLine("End of data transfer.") 
         End If 
 
         If Not e.Image Is Nothing Then 
            ' You can load the image here. 
         End If 
 
         e.Cancel = False 
      End Sub 
using Leadtools; 
      using Leadtools.Codecs; 
      using Leadtools.Wia; 
 
      [TestMethod] 
#if !LEADTOOLS_V19_OR_LATER 
      public void IsAvailableExample(IWin32Window parent) 
#else 
      public void IsAvailableExample(IntPtr parent) 
#endif // #if !LEADTOOLS_V19_OR_LATER 
      { 
         if ( !WiaSession.IsAvailable(WiaVersion.Version1) ) 
         { 
            MessageBox.Show("WIA version 1.0 not installed."); 
            return; 
         } 
         WiaSession wiaSession = new WiaSession(); 
         wiaSession.Startup(WiaVersion.Version1); 
 
         DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
         if(res != DialogResult.OK) 
         { 
            MessageBox.Show("Error selecting WIA device."); 
            wiaSession.Shutdown(); 
            return; 
         } 
 
         // Initialize and fill the required fields from the WiaAcquireOptions structure 
         WiaAcquireOptions wiaAcquireOptions = WiaAcquireOptions.Empty; 
         wiaAcquireOptions.MemoryBufferSize = 32 * 1024; 
         wiaAcquireOptions.DoubleBuffer = true; 
         wiaSession.AcquireOptions = wiaAcquireOptions; 
 
         wiaSession.AcquireEvent += new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent); 
 
         wiaSession.Acquire(parent, null, WiaAcquireFlags.ShowUserInterface |   WiaAcquireFlags.UseCommonUI); 
 
         wiaSession.AcquireEvent -= new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent); 
         wiaSession.Shutdown(); 
      } 
 
      public void wiaSession_AcquireEvent(object sender, WiaAcquireEventArgs e) 
      { 
         Application.DoEvents(); 
 
         if ((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage) 
            Console.WriteLine("Beginning of data transfer."); 
         else if ((e.Flags & WiaAcquiredPageFlags.EndOfPage) == WiaAcquiredPageFlags.EndOfPage) 
            Console.WriteLine("End of data transfer."); 
 
         if (e.Image != null) 
         { 
            // You can load the image here. 
         } 
 
         e.Cancel = false; 
      } 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Wia Assembly
Click or drag to resize