L_WiaGetRootItem

#include "ltwia.h"

L_LTWIA_API L_INT EXT_FUNCTION L_WiaGetRootItem(hSession, pItem, ppWiaRootItem)

Gets the root item for the passed pItem parameter.

Parameters

HWIASESSION hSession

Handle to an existing WIA session. This handle is obtained by calling the L_WiaInitSession function.

L_VOID* pItem

Valid pointer to a type IWiaItem or IWiaItem2 object (IWiaItem if using WIA Version 1.0; IWiaItem2 if using WIA Version 2.0), which represents the item for which you wish to retrieve its root item.

If this parameter is NULL, then the ppWiaRootItem parameter will be filled with pointer to the device's root item.

L_VOID ** ppWiaRootItem

Address of the pointer to IWiaItem or IWiaItem2 interface variable to be updated with the root item for the item passed through the pItem parameter.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This feature is available in version 16 or higher.

Gets the root item for the item passed through the pItem parameter.

If pItem is NULL then the ppWiaRootItem parameter will be updated with a pointer to the device's root item (which represents the device itself).

This is the first function you need to call to get a pointer to the device's root item. Then pass that pointer to the L_WiaEnumChildItems function to enumerate all of the device's child items. Then call this function again for any child item of the enumerated items to retrieve its root item if needed.

Required DLLs and Libraries

Platforms

LEADTOOLS WIA supports both 32-bit and 64-bit image acquisition for both WIA 1.0 (XP and earlier) and WIA 2.0 (VISTA and later).

See Also

Functions

Topics

Example

L_INT EXT_CALLBACK WiaSetItemPropertiesCB(HWIASESSION hSession, 
                                          L_INT PropertyID, 
                                          L_INT nError, 
                                          L_UINT uValueType, 
                                          L_VOID * pValue, 
                                          L_VOID * pUserData) 
{ 
   UNREFERENCED_PARAMETER(hSession); 
   UNREFERENCED_PARAMETER(pUserData); 
   UNREFERENCED_PARAMETER(uValueType); 
 
   L_TCHAR szMsg[MAX_PATH] = TEXT(""); 
 
   if(nError != WIA_SUCCESS) 
   { 
      /* Display error message for the user to inform him about the failed property set */ 
      wsprintf(szMsg,  
               TEXT("Failed to set the property below:\n\n") 
               TEXT("Property ID: %n.\n") 
               TEXT("User Value: %n.\n") 
               TEXT("Error Code: %n."), 
               PropertyID, (*(L_INT*)pValue), nError); 
 
      MessageBox(NULL, szMsg, TEXT("ERROR"), MB_OK|MB_ICONERROR); 
   } 
   return WIA_SUCCESS; 
} 
 
static L_INT CALLBACK WiaEnumItemsCB(HWIASESSION hSession, 
                                     L_INT nItemsCount, 
                                     L_VOID * pItem, 
                                     L_VOID * pUserData) 
{ 
   UNREFERENCED_PARAMETER(nItemsCount); 
   UNREFERENCED_PARAMETER(pUserData); 
    
   L_INT nRet; 
   GUID guid; 
   LWIAPROPERTIES WiaProps; 
   LWIADATATRANSFER DataTransfer; 
   LWIAIMAGEEFFECTS ImageEffects; 
   LWIAIMAGERESOLUTION ImageResolution; 
 
   memset(&guid, 0, sizeof(guid)); 
 
   memset(&DataTransfer, 0, sizeof(DataTransfer)); 
   DataTransfer.uStructSize = sizeof(DataTransfer); 
   DataTransfer.pguidFormat = &guid; 
 
   memset(&ImageEffects, 0, sizeof(ImageEffects)); 
   ImageEffects.uStructSize = sizeof(ImageEffects); 
 
   memset(&ImageResolution, 0, sizeof(ImageResolution)); 
   ImageResolution.uStructSize = sizeof(ImageResolution); 
    
 
   memset(&WiaProps, 0, sizeof(WiaProps)); 
   WiaProps.uStructSize = sizeof(WiaProps); 
 
   WiaProps.pDataTransfer = &DataTransfer; 
   WiaProps.pImageEffects = &ImageEffects; 
   WiaProps.pImageResolution = &ImageResolution; 
    
   if(pItem != NULL) 
   {       
      /* Get the current properties for the received item */ 
      nRet = L_WiaGetProperties(hSession, pItem, &WiaProps); 
      if(nRet != WIA_SUCCESS) 
         return nRet; 
 
      /* Change some of the item's properties */ 
      WiaProps.nMaxNumOfPages = ALL_PAGES; 
      WiaProps.pDataTransfer->nImageDataType = WIA_DATA_GRAYSCALE; 
      WiaProps.pImageEffects->nBrightness = 50; 
 
      /* Set back the received item properties */ 
      nRet = L_WiaSetProperties(hSession, pItem, &WiaProps, WiaSetItemPropertiesCB, NULL); 
      if(nRet != WIA_SUCCESS) 
         return nRet; 
 
      nRet = L_WiaFreeItem(hSession, pItem); 
      if(nRet != WIA_SUCCESS) 
         return nRet; 
   } 
    
   return WIA_SUCCESS; 
} 
 
L_INT WiaGetRootItemExample(HWIASESSION hSession, HWND hWnd) 
{ 
   IWiaItem * pRootItem = NULL; 
   L_INT nRet; 
 
   nRet = L_WiaSelectDeviceDlg(hSession, hWnd, WiaDeviceTypeDefault, 0); 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   /* Get a pointer to the WIA device's root items */ 
   nRet = L_WiaGetRootItem(hSession, NULL, (L_VOID**)&pRootItem); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_WiaEnumChildItems(hSession, pRootItem, WiaEnumItemsCB, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   pRootItem->Release(); 
 
   return SUCCESS; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS WIA C API Help

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