阅读:1522回复:5
如何在运用程序中调用DLL
各位大虾,你们好,我自己生成了一个动态连接文件DLL,但不知如何才能把它用到运用程序中(指隐含连接),请告诉我具体的详细步骤好吗?谢谢各位了
|
|
沙发#
发布于:2004-11-18 20:40
你是不是作了一个驱动,想用?
我不太清楚别的操作系统下的驱动如何调用,但我想都是有相同之处的。 我知道如何调用wince下的流接口驱动,挺简单,就用读写文件的函数ReadFile和WriteFile就可以了,当打开文件的时候用的是如 COM:1这样的文件名。 但是,驱动是不能用LoadLibrary这样调用的,原因见下面,说的是wince下的驱动,但是我觉得应该都是可以的。 A device driver isn't loaded by the application communicating with the driver. Instead, the device manager, Device.exe, loads most drivers, including all stream drivers. This state of affairs affects the driver in two ways. First, an application can't simply call private entry points in a driver as it can in a DLL. The only way an application could directly call an entry point would be if it called LoadLibrary and GetProcAddress to get the address of the entry point so the entry point could be called. This situation would result in the DLL that implemented the driver (notice I'm not calling it a driver anymore) being loaded in the process space of the application, not in the process space of the device manager. The problem is that this second copy of the DLL isn't the driver―it's the DLL that implemented the driver. The difference is that the first copy of the DLL (the driver)―when properly loaded by the device manager―has some state data associated with it that isn't present in the second copy of the DLL loaded by the application. Perversely, the calls to LoadLibrary and GetProcAddress will succeed because the driver is a DLL. In addition, calling the entry points in the driver results in calling the correct code. The problem is that the code will be acting on data present only in the second copy of the DLL, not in the proper data maintained by the driver. This situation can, and usually does, result in subtle bugs that can confuse and even lock up the hardware the driver is managing. In short, never interact with a driver by calling LoadLibrary and GetProcAddress. 由于刚学,好多不会,所以讲不明白。应该会有高手出现的。 祝好运! |
|
板凳#
发布于:2004-11-18 21:55
用Loadlibrary(),去MSDN上随便找个例子吧。
|
|
|
地板#
发布于:2004-11-19 13:44
LoadLibrary()的例子还是很好用的呀,呵呵,特别是隐性链接。
|
|
|
地下室#
发布于:2004-11-19 15:32
在本论坛搜索 阿蒙的动态链接库DLL编程资料(CHM)
|
|
5楼#
发布于:2004-11-19 15:47
用Loadlibrary()可以实现DLL的动态连接
|
|