The GetAduDeviceList function accepts an empty list of
ADU_DEVICE_IDs, and populates it with all currently connected
ADU devices. Call this function to obtain a list of ADU Product
IDs and Serial Numbers of connected ADU devices.
Return code is supplied by the driver via bResult argument.
bResult will be TRUE if pAduDeviceList was populated, FALSE if
something went wrong. See “Notes” below.
If the number of devices specified by iAduDeviceListBufferSize
is smaller than the number of currently connected ADU devices,
the result value will be FALSE. In this case, the data contained
in pAduDeviceList should not be trusted, and the function should
be called with a larger list of ADU_DEVICE_IDs.
iAduDeviceListBufferSize should always be the number of
ADU_DEVICE_IDs declared in pAduDeviceList.
/*
The following
code will:
- retrieve a
list of ADU devices from the AduHid.dll (or AduHid64.dll)
driver;
- step through
the list identifying each ADU's Product ID & Serial Number;
- build a string
list of all connected ADUs;
- display the
list in a Message Box.
*/
// Max number of
ADUs in the device list
const int
ADU_DEVICE_MAX = 128;
// Allocating space
for the driver to return data
ADU_DEVICE_ID
pAduDevices[ADU_DEVICE_MAX];
unsigned
short nNumDevicesFound;
BOOL
bResult;
// To provide the
driver with a time limit
unsigned long
nTimeoutMillisec = 100;
// For displaying a
list of devices
CString
strProductID;
CString
strSerialNum;
CString
strOutputBuffer;
CString
strOutputString;
// Call the Driver
DLL to retrieve a list of connected ADU devices.
GetAduDeviceList(pAduDevices,
ADU_DEVICE_MAX, nTimeoutMillisec, &nNumDevicesFound,
&bResult);
// bResult is FALSE
if there was an error, or more than ADU_DEVICE_MAX devices
if(bResult
== TRUE)
{
// nNumDevicesFound contains
the number of ADUs returned by the driver
strOutputString.Format(_T("Devices
found: %i\n"), nNumDevicesFound);
// now stepping through each
device
for (int
x = 0; x < nNumDevicesFound; x++)
{
// Obtain the ADU's product ID
& serial number
strProductID.Format(_T("%d"),
pAduDevices[x].iProductId);
strSerialNum = pAduDevices[x].szSerialNumber;
// Format the ADU index,
Product ID & SNo, then add it to the output string
strOutputBuffer.Format(_T("%i:
%s, %s\n"), x, strProductID, strSerialNum);
strOutputString.Append(strOutputBuffer);
}
// Show our device list in a
Message Box
MessageBox (strOutputString);
}