首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

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

2012-01-02 
调用DLL问题,实在搞不定,急救!在线等vc6.0写的 CodeLib.dll 里有一这样的函数:intsearchmachine(BytecPort

调用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()

热点排行