Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prohibit FTDI .NET DLL from alerting user when drivers are not installed

I have a C# application that's using the FTD2XX.DLL from FTDI. This application is used for multiple generations of a single product and abstracts the physical hardware. There's an FTDI and a HID implementation.

The application searches for both appropriate FTDI and HID devices, though it's likely that no FTDI drivers exist if the user has the HID generation.

Background aside now. When I instantiate the FTDI class I get a modal, not generated by my code about not finding the FTDI driver and asks the user if the drivers are installed. I tried wrapping this in a TRY/CATCH block but no exception is thrown.

1: Is there a way to determine if the FTDI drivers are installed before trying to instantiate the FTDI class?

2: If not, is there a way to prohibit the FTDI dll from alerting the user when this happens?

like image 806
Ken Farr Avatar asked Mar 11 '11 17:03

Ken Farr


People also ask

Does Windows 10 have FTDI drivers?

There are different versions of the FTDI Driver for Windows 10/11 as shown in Figure 1.1. *Includes the following version of the Windows operating system: Windows 7, Windows 8/8.1, Windows 10, Windows 11, Windows Server 2008 R2 and Windows server 2012 R2. ****Windows 10 and Windows 11 only.

How do I uninstall FTDI drivers Windows 10?

Open the Add/Remove Programs utility located in "Control Panel\Add/Remove Programs". Select "FTDI USB-Serial Converter Drivers" from the list of installed programs. Click the "Add/Remove" button. This will run the FTDI uninstaller program.

What is D2XX driver?

D2XX drivers allow direct access to the USB device through a DLL. Application software can access the USB device through a series of DLL function calls. The functions available are listed in the D2XX Programmer's Guide document which is available from the. Documents section of this site.

What is FTDI CDM Driver?

What is a FTDI driver? Future Technology Devices International is commonly known as FTDI, a company specializing in USB technology. FTDI driver is a essential software that communicates between your computer system and FTDI hardware device.


2 Answers

I have the exact same requirements - in my case I'm enumerating the list of standard serial ports and appending this with the list of any attached FTDI devices. If the driver isn't installed, then I'd like to not have those modal dialog boxes appear. One quick and dirty way I've figured out to do this is to check for the file FTD2XX.DLL being in c:\windows\system32 (or wherever windows is installed). The existence of this file basically means the driver is installed.

// c# example
string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
bool installed = File.Exists(path + Path.DirectorySeparatorChar + "FTD2XX.DLL");
like image 167
dodgy_coder Avatar answered Sep 23 '22 18:09

dodgy_coder


Another way:

[DllImport("kernel32.dll")]
private static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
private static extern bool FreeLibrary(IntPtr hModule);    

public bool IsDriverInstalled()
{
  //trying to load library
  IntPtr handler = LoadLibrary(@"FTD2XX.DLL");

  if (handler == IntPtr.Zero)
      return false;
  else
      return true; // Driver is installed

  //Don't forget to free .dll
  FreeLibrary(handler);
}
like image 21
somedev Avatar answered Sep 25 '22 18:09

somedev