views:

56

answers:

1

Hi,
Im working with a CD722UN Customer Display for our POS application.

it comes with a USB2.0 connection and a installation package containing a driver ect..

now, for my application. how should i do when i want to access this driver?

at the moment i'm using the "CD722UN application"s .dll path but that can warry from clients OS ect..

    Declare Function opencd722usb Lib "C:\Program\cd7220 USB\cd722dusb.dll" () As Boolean
    Declare Function writecd722usb Lib "C:\Program\cd7220 USB\cd722dusb.dll" (ByRef dataoutput As Byte, ByVal Length As Integer) As Integer
    Declare Function readcd722usb Lib "C:\Program\cd7220 USB\cd722dusb.dll" (ByRef DataInput As Byte, ByVal size As Integer) As Integer
    Declare Function closecd722usb Lib "C:\Program\cd7220 USB\cd722dusb.dll" () As Boolean

my first thought was to first check if there was a device installed in the device manager and somehow use the driver from there???
or
distribute the .dll inside our application folder and use
searchpath ""installed directory"\cd722dusb.dll"

what is the best solution?

thanks in advance!

+1  A: 

Figuring out how to access the device yourself is not typically a good idea when you have zero documentation on how to do so properly. There are too many possibilities and the code can be quite awkward in a managed language. You probably can't even get any documentation if the supplier already provides an access DLL.

The odds are pretty good that this DLL will work if you simply copy the DLL into the same folder as your EXE. Try that first, only the DLL name is required in the Declare statement. Look in the install directory for other DLLs that might need to be copied as well if you have trouble. The next option is to P/Invoke the SetDllDirectory() function if you can discover the path at runtime. The next option is to have the installer add the directory that contains the DLL to the system PATH environment variable. Hard-coding the path is your last resort.

Hans Passant
awesome! that is what i will be doing then. option nr1 and include it in my installed application folder! (: thank you once again
Alexander