It sounds like you are associating FTD2XX.DLL with your application.
You should not do this, you should use the latest DLL installed in the Windows system directory by the FTDI driver. If you have an old version of the DLL in the application directory and the user has newer drivers (possibly installed by some other FTDI-based device), you may have all kinds of problems.
As a bonus, this solves your problem in most cases: if FTD2XX.DLL is not installed on the system, you will get an exception trying to execute p / invoke, which you can catch.
However, to avoid the error, you need to perform the same check that FTD2XX.DLL does internally (since the DLL can obviously exist on the system without any driver). For example, checking for a driver in the registry under HKLM\System\CurrentControlSet\services will be a more reliable check than the one you have. Still not sure if this is equivalent to FTDI's own validation.
source share