读书人

调用DLL有关问题实在搞不定救

发布时间: 2012-01-02 22:40:04 作者: rapoo

调用DLL问题,实在搞不定,急救!在线等
vc6.0写的 CodeLib.dll 里有一这样的函数:
int searchmachine (Byte cPort,Dword dwBaudRate,Byte cStar,byte cEnd,char *pSearchResult)
我在VB中这样声明:
Declare Function SearchMachine Lib "CodeLib.dll " (ByVal cPort As Byte, ByVal dwBaudRate As Long, ByVal cStar As Byte, ByVal cEnd As Byte, ByRef pSearchResult As Byte) As Integer
然后在一处这样调用:
dim i as integer
dim cpor as byte
dim k as byte
dim cmachineno(4) as byte
cpor=1
k=4
i = SearchMachine(cpor, dwBaudRate, 0, k, cmachineno(0))
结果为:I为0说明正确执行
且cmachineno()数组里也得出了想要的结果.
可是当关闭整个VB时出现了这样的情况:
内存不能为"written"
如果生成exe执行,也会出现这样的情况
是什么原因呢?请高手们帮忙,只要用到带有指针的函数都会出现那样的情况


[解决办法]
你还是把,char *pSearchResult对应项改为byval pSearchResult as string吧
[解决办法]
代码基本没错
char *pSearchResult对应ByRef pSearchResult As Byte()

读书人网 >VB

热点推荐