public GetNumberOfDevices ( |
||
devcount | The number of FTDI devices available. | |
return | FT_STATUS |
public FT_STATUS GetNumberOfDevices(ref UInt32 devcount)
{
// Initialise ftStatus to something other than FT_OK
FT_STATUS ftStatus = FT_STATUS.FT_OTHER_ERROR;
// If the DLL hasn't been loaded, just return here
if (hFTD2XXDLL == IntPtr.Zero)
return ftStatus;
// Check for our required function pointers being set up
if (pFT_CreateDeviceInfoList != IntPtr.Zero)
{
tFT_CreateDeviceInfoList FT_CreateDeviceInfoList = (tFT_CreateDeviceInfoList)Marshal.GetDelegateForFunctionPointer(pFT_CreateDeviceInfoList, typeof(tFT_CreateDeviceInfoList));
// Call FT_CreateDeviceInfoList
ftStatus = FT_CreateDeviceInfoList(ref devcount);
}
else
{
LogB.Debug("FTD2XX: Failed to load function FT_CreateDeviceInfoList.");
}
return ftStatus;
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { FTD2XX_NET.FTDI dev = new FTDI(); UInt32 numDevices = 0; dev.GetNumberOfDevices(ref numDevices); var pDest = new FTD2XX_NET.FTDI.FT_DEVICE_INFO_NODE[numDevices]; dev.GetDeviceList(pDest); VIDPIDList = string.Empty; for (int i = 0; i < numDevices; i++ ) { VIDPIDList += string.Format("{0} \n", pDest[i].ID); } }