←Select platform

Startup Method

Summary
Initializes the WIA session.

Syntax
C#
C++/CLI
Python
public void Startup( 
   WiaVersion version 
) 
public: 
void Startup(  
   WiaVersion version 
)  
def Startup(self,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.
Remarks

This method should be called before calling any other method in LEADTOOLS WIA toolkit. Likewise, when the handle to the WIA session is no longer needed, it should be ended by calling Shutdown method. For every call to Startup there must be a call to Shutdown.

Call the IsAvailable method to determine whether a WIA source with the specified version is installed.

Note:

You do not need to call Startup if you are using the high-level AcquireSimple method, since it handles session initialization, session end, and device selection automatically.

For more information, refer to Initializing a WIA Session.

For more information, refer to Freeing the WIA Session.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
 
 
      
public void IsAvailableExample(IntPtr parent) 
{ 
   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
   { 
      Console.WriteLine("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) 
   { 
      Console.WriteLine("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

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Wia Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.