最好的解决方案使用DLL /驱动程序? [英] best solution to use a DLL/Driver?

查看:460
本文介绍了最好的解决方案使用DLL /驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



它配有一个USB2.0连接和一个包含驱动程序的安装包。 p>

现在,对于我的应用程序。当我想要访问此驱动程序时,该怎么办?



目前我正在使用CD722UN应用程序的.dll路径,但可以从客户端操作系统ect ..

 声明函数opencd722usb LibC:\Program\cd7220 USB\cd722dusb.dll()As Boolean 
声明函数writecd722usb LibC:\Program\cd7220 USB\cd722dusb.dll(ByRef dataoutput As Byte,ByVal Length As Integer)As Integer
声明函数readcd722usb LibC:\\ \\ Program \cd7220 USB\cd722dusb.dll(ByRef DataInput As Byte,ByVal size As Integer)As Integer
声明函数closecd722usb LibC:\Program\cd7220 USB\cd722dusb.dll( )作为布尔值

我的第一个想法是首先检查设备管理器中是否安装了一个设备,以某种方式使用驱动程序?



在我们的应用程序文件夹内分发.dll,并使用

searchpath 安装目录\cd722dusb.dll



什么是最好的解决方案?



提前谢谢

解决方案

想知道如何自己访问设备通常不是一个好主意您有关于如何正确执行的零文档。有太多的可能性,代码在管理语言中可能相当尴尬。如果供应商已经提供访问DLL,您可能甚至不能获得任何文档。



如果您只是将DLL复制到DLL中,这个DLL将会起作用与您的EXE相同的文件夹。首先尝试,在Declare语句中只需要DLL名称。在安装目录中查找可能需要复制的其他DLL,如果您遇到问题。下一个选项是P / Invoke SetDllDirectory()函数,如果您可以在运行时发现路径。下一个选项是让安装程序将包含该DLL的目录添加到系统PATH环境变量中。


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!

解决方案

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.

这篇关于最好的解决方案使用DLL /驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆