EnumChildItems Method

Enumerates all available child items for the root item specified in the
parentItem parameter.
public void EnumChildItems( 
   object parentItem 
void EnumChildItems(  
   Object^ parentItem 


Handle to the item which represents the root item having its child items enumerated.


The WIA run-time system represents each WIA hardware device in a hierarchical tree of items. This function enables applications to enumerate the child items for the specified root item.

Pass a valid parentItem parameter. To do so, retrieve a pointer to the device's root Item itself by calling the GetRootItem method and then pass the retrieved item to the EnumChildItems method as the parent item for the child items.

Each enumerated item will be sent to the user through the EnumItemsEvent event. Add this event when enumerating the device's child items. To cancel the enumeration proces, add the EnumItemsEvent event and then set the Cancel member of the WiaEnumItemsEventArgs to true.

For each received item through the EnumItemsEvent event call FreeItem method. Save the received items in a list or array and when the list is not needed anymore, loop through the list items and call the FreeItem method for each of them.

For more information, refer to Managing WIA Sources.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
WiaSession wiaSession; 
public void GetRootItemExample(IntPtr parent) 
   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
      Console.WriteLine("WIA version 1.0 not installed."); 
   wiaSession = new WiaSession(); 
   DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
   if (res != DialogResult.OK) 
      Console.WriteLine("Error selecting WIA device."); 
   object rootItem = wiaSession.GetRootItem(null); 
   if (rootItem != null) 
      wiaSession.EnumItemsEvent += new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent); 
      wiaSession.EnumItemsEvent -= new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent); 
void wiaSession_EnumItemsEvent(object sender, WiaEnumItemsEventArgs e) 
   if (e.Item != null) 
      WiaDataTransferProperties dataTransfer = WiaDataTransferProperties.Empty; 
      WiaImageEffectsProperties imageEffects = WiaImageEffectsProperties.Empty; 
      WiaProperties properties = wiaSession.GetProperties(e.Item); 
      dataTransfer.ImageDataType = WiaImageDataType.Grayscale; 
      imageEffects.Brightness = 250; 
      properties.DataTransfer = dataTransfer; 
      properties.ImageEffects = imageEffects; 
      properties.ScanningMode = WiaScanningModeFlags.Feeder;   // set scanning source to Feeder 
      properties.MaximumNumberOfPages = 0;                     // scan all pages in feeder 
      properties.ImageType = WiaImageType.Grayscale; 
      properties.Orientation = WiaOrientation.Portrait; 
      WiaImageResolutionProperties imageResolution = properties.ImageResolution; 
      imageResolution.BitsPerPixel = 8; 
      imageResolution.HorizontalResolution = 600; 
      imageResolution.VerticalResolution = 600; 
      properties.ImageResolution = imageResolution; 
      wiaSession.SetPropertiesEvent += new EventHandler<WiaSetPropertiesEventArgs>(wiaSession_SetPropertiesEvent); 
      wiaSession.SetProperties(e.Item, properties); 
      wiaSession.SetPropertiesEvent -= new EventHandler<WiaSetPropertiesEventArgs>(wiaSession_SetPropertiesEvent); 
void wiaSession_SetPropertiesEvent(object sender, WiaSetPropertiesEventArgs e) 
   if (e.Error <= 0) 
      Console.WriteLine("Failed to set the below property:\n\tProperty Id: {0}\n\tProperty Value: {1}\n\tError: {2}\n\n", e.PropertyId.ToString(), e.Value.ToString(), e.Error.ToString()); 

Target Platforms

Help Version 22.0.2023.1.17
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.