L_WiaEnumDevices

#include "ltwia.h"

L_LTWIA_API L_INT EXT_FUNCTION L_WiaEnumDevices(hSession, pfnCallBack, pUserData)

Enumerates all available system WIA devices connected to the user machine.

Parameters

HWIASESSION hSession

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

LWIAENUMDEVICESCALLBACK pfnCallBack

Pointer to an optional callback the user can use to retrieve information about the found WIA device such as device ID, device name and device description.

L_VOID * pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

If the additional parameters are not needed, you can pass NULL in this 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.

This function will enumerate all available system WIA devices connected to the user machine. It uses a callback that sends the user information about each WIA device found, like device ID, device name and device description.

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

static L_INT CALLBACK WiaEnumDevicesCB(HWIASESSION hSession,  
                                       pLWIADEVICEID pDeviceID,  
                                       L_VOID * pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
 
   L_INT nRet; 
   L_UINT uDevType; 
   L_TCHAR szSelectedDeviceID[MAX_PATH] = TEXT(""); 
   L_TCHAR szMsg[MAX_PATH] = TEXT(""); 
 
   /* Select the received device */ 
   if(pDeviceID) 
   { 
      if(pDeviceID->pszDeviceId) 
      { 
         nRet = L_WiaSelectDevice(hSession, pDeviceID->pszDeviceId); 
      } 
   } 
 
   /* Get the selected device type */ 
   nRet = L_WiaGetSelectedDeviceType(hSession, &uDevType); 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   if(uDevType == WiaDeviceTypeScanner) 
   { 
      /* Make sure the device was selected successfully */ 
      lstrcpy(szSelectedDeviceID, L_WiaGetSelectedDevice(hSession)); 
      wsprintf(szMsg, TEXT("Scanner device with the device ID <%s> selected."), szSelectedDeviceID); 
      MessageBox(NULL, szMsg, TEXT("Information"), MB_OK|MB_ICONINFORMATION); 
   } 
 
   return WIA_SUCCESS; 
} 
 
L_INT WiaEnumDevicesExample(HWIASESSION hSession) 
{ 
   L_INT nRet; 
 
   nRet = L_WiaEnumDevices(hSession, WiaEnumDevicesCB, NULL); 
   if (nRet != WIA_SUCCESS) 
      return FALSE;  
 
   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.