回复 10楼 TonyDeng
嗯,老板让我继续研究一下VFP怎么读DLL,说没道理读不了,肯定还是我没用对。实在不行他用VB给我把数据写到DDE里,VFP就可以用了。 我不太了解DDE,也是倾向于用VFP去直接读取卡input进来的数据,不行再像您说的VB写到文本里再用VFP读。
不知道神叔叔什么时候有时间可以看一下为什么偶用不了那个库文件cbw32.dll
也不知道是不是我用的不对。不是declare就可以了么?set library to cbw32.dll就不能用,说Invalid。
下面是我自己写的几行代码,想看一下cbDIn()会不会传值回来,结果不行。
在VB的例程里,可以看到PortNum如果是FIRSTPORTA,值为10,所以我就直接给了个10,不知道可不可以这样用。关键是如果您有时间,有兴趣的话我也可以把例程发给您。
在此谢过花时间看帖的好人。
**********************************************************************************************
DECLARE Integer cbDConfigPort IN cbw32.dll Long, Long, Long
DECLARE Integer cbDIn IN cbw32.dll Long, Long, Integer
#Define BoardNum 0
#Define DIGITALIN 2
#Define PortNum 10
PUBLIC ULStat as Long
LOCAL DataValue as Integer
Direction = DIGITALIN
ULStat = cbDConfigPort(BoardNum, PortNum, Direction)
&&ULStat值为0
ULStat = cbDIn(BoardNum, PortNum, DataValue)
&&报错:Declare DLL call caused an exception
?DataValue
&& 值为F
?ULStat
&& 值为0
*************************************************************************************************
cbDConfigPort()的功能:Configures a digital port as input or output
函数原型:
C/C++
int cbDConfigPort(int BoardNum, int PortNum, int Direction)
Visual Basic
Function cbDConfigPort(ByVal BoardNum&, ByVal PortNum&, ByVal Direction&) As Long
三个变量的定义为:
BoardNum
The number associated with the board when it was installed with InstaCal. BoardNum may be 0 to 99.
PortNum
The specified port must be configurable. For most boards, AUXPORT is not configurable. Check the board-specific information in the Universal Library User's Guide for details.
Direction
DIGITALOUT or DIGITALIN configures the entire eight or four bit port for output or input.
返回:Error code or 0 if no errors
cbDIn()的功能:Reads a digital input port.
函数原型:
C/C++
int cbDIn(int BoardNum, int PortNum, unsigned short *DataValue)
Visual Basic
Function cbDIn(ByVal BoardNum&, ByVal PortNum&, DataValue%) As Long
三个变量的定义:
BoardNum
The number associated with the board when it was installed with InstaCal. BoardNum may be 0 to 99.
PortNum
Specifies which digital I/O port to read. Some hardware does allow readback of the state of the output using this function. Check the board-specific information in the Universal Library User's Guide.
DataValue
Digital input value returned here.
返回:
Error code or 0 if no errors
DataValue - Digital input value returned here
[
本帖最后由 Bunny008 于 2012-3-9 23:02 编辑 ]