0

In my VB .NET project, I have several functions that use unmanaged code from within winusb.dll. I tested the code on some machine which haven't drivers installed at all (winusb) and of course errors appears: "Unable to load winusb.dll...."

Now I don't want to try/catch every function imported since will drop performances (or not?) and instead, I'm thinking to use some check in my component constructor for presence of winusb.dll, raise error event and inhibit all functions until next program start. All functions are pointless without that dll. This is a good approach?

Now how can I check reliable for all platforms (xp, wista,7,8) for presence of that dll? I need a expert opinion to optimum solve the problem and thanks very much in advance.

user1797147
  • 915
  • 3
  • 14
  • 33

1 Answers1

0
    If System.IO.File.Exists("C:\Windows\System32\winusb.dll") Then
        ' go ahead
    Else
        ' abort
    End If

A better approach however would be to install the winusb library along with your application. An installer that doesn't install all required libraries is pretty worthless.

Steven Liekens
  • 13,266
  • 8
  • 59
  • 85