FTD2XX_NET.FTDI.GetDeviceID C# (CSharp) Method

GetDeviceID() public method

Gets the Vendor ID and Product ID of the current device.
public GetDeviceID ( UInt32 &DeviceID ) : FT_STATUS
DeviceID System.UInt32 The device ID (Vendor ID and Product ID) of the current device.
return FT_STATUS
        public FT_STATUS GetDeviceID(ref UInt32 DeviceID)
        {
            // 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_GetDeviceInfo != IntPtr.Zero)
            {
                tFT_GetDeviceInfo FT_GetDeviceInfo = (tFT_GetDeviceInfo)Marshal.GetDelegateForFunctionPointer(pFT_GetDeviceInfo, typeof(tFT_GetDeviceInfo));

                FT_DEVICE DeviceType = FT_DEVICE.FT_DEVICE_UNKNOWN;
                byte[] sernum = new byte[16];
                byte[] desc = new byte[64];

                if (ftHandle != IntPtr.Zero)
                {
                    // Call FT_GetDeviceInfo
                    ftStatus = FT_GetDeviceInfo(ftHandle, ref DeviceType, ref DeviceID, sernum, desc, IntPtr.Zero);
                }
            }
            else
            {
                if (pFT_GetDeviceInfo == IntPtr.Zero)
                {
                    LogB.Debug("FTD2XX: Failed to load function FT_GetDeviceInfo.");
                }
            }
            return ftStatus;
        }