←Select platform

GetCategoryGuid Method

Summary
Retrieves the relevant System.Guid structure for the WIA 2.0 item's category.

Syntax
C#
C++/CLI
Python
public static Guid GetCategoryGuid( 
   WiaCategories category 
) 
public: 
static Guid GetCategoryGuid(  
   WiaCategories category 
)  
def GetCategoryGuid(self,category): 

Parameters

category
The WIA 2.0 item category ID. For a list of available categories, refer to WiaCategories.

Return Value

The relevant System.Guid value for the category Id passed as parameter for the GetCategoryGuid method.

Remarks

This method is only used when using WIA version 2.0. Each WIA 2.0 item has a category represented as a System.Guid structure that can be retrieved by calling the GetPropertyGuid method, and passing the WiaPropertyId.ItemCategory for the propertyId parameter of this method. To determine the relevant category for returned System.Guid values, call the GetCategoryGuid method for each available category in the WiaCategories enumeration and then compare the returned System.Guid values with this one.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
 
 
WiaSession mySession; 
 
public void GetPropertyGuidExample(IntPtr parent) 
{ 
   if (!WiaSession.IsAvailable(WiaVersion.Version2)) 
   { 
      Console.WriteLine("WIA version 2.0 not installed."); 
      return; 
   } 
 
   mySession = new WiaSession(); 
   mySession.Startup(WiaVersion.Version2); 
 
   DialogResult res = mySession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
   if (res != DialogResult.OK) 
   { 
      Console.WriteLine("Error selecting WIA device."); 
      mySession.Shutdown(); 
      return; 
   } 
 
   object rootItem = mySession.GetRootItem(null); 
   if (rootItem != null) 
   { 
      mySession.EnumItemsEvent += new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent3); 
 
      mySession.EnumChildItems(rootItem); 
 
      mySession.EnumItemsEvent -= new EventHandler<WiaEnumItemsEventArgs>(wiaSession_EnumItemsEvent3); 
   } 
 
   mySession.Shutdown(); 
} 
 
void wiaSession_EnumItemsEvent3(object sender, WiaEnumItemsEventArgs e) 
{ 
   bool found = false; 
 
   if (e.Item != null) 
   { 
      // Read the item category property (this property is only available for WIA 2.0). 
      Guid sessionCategoryGuid = mySession.GetPropertyGuid(e.Item, null, WiaPropertyId.ItemCategory); 
 
      // Find the related item category for the received Guid. 
      Guid categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.Feeder); 
      if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
      { 
         Console.WriteLine("Item category: Feeder"); 
         found = true; 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.FeederBack); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: FeederBack"); 
            found = true; 
         } 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.FeederFront); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: FeederFront"); 
            found = true; 
         } 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.Film); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: Film"); 
            found = true; 
         } 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.FinishedFile); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: FinishedFile"); 
            found = true; 
         } 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.Flatbed); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: Flatbed"); 
            found = true; 
         } 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.Folder); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: Folder"); 
            found = true; 
         } 
      } 
 
      if (found == false) 
      { 
         categoryGuid = WiaSession.GetCategoryGuid(WiaCategories.Root); 
         if (categoryGuid == sessionCategoryGuid)   // the item is a Feeder. 
         { 
            Console.WriteLine("Item category: Root"); 
            found = true; 
         } 
      } 
 
      mySession.FreeItem(e.Item); 
   } 
} 
Requirements

Target Platforms

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

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