L_WiaEnumDevices

#include "ltwia.h"

L_LTWIA_API L_INT EXT_FUNCTION L_WiaEnumDevices(hSession, pfnCallBack, pUserData)

HWIASESSION hSession;

/* handle to an existing WIA session */

LWIAENUMDEVICESCALLBACK pfnCallBack;

/* pointer to an optional callback function */

L_VOID * pUserData;

/* pointer to additional parameters */

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

Parameter

Description

hSession

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

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.

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

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

LTWIA

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Earlier and later operating systems than Windows XP for WIA Version 1.

Windows VISTA or later for WIA Version 2.

See Also

Functions:

L_WiaAcquire, L_WiaAcquireToFile, L_WiaAcquireSimple, L_WiaInitSession, L_WiaEndSession, LWIAENUMDEVICESCALLBACK.

Topics:

Managing WIA Sources

 

WIA Functionality: Property Functions

 

WIA Functionality: Callbacks

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_LTWIATEX_API L_INT WiaEnumDevicesExample(HWIASESSION hSession)
{
   L_INT nRet;

   nRet = L_WiaEnumDevices(hSession, WiaEnumDevicesCB, NULL);
   if (nRet != WIA_SUCCESS)
      return FALSE; 

   return SUCCESS;
}