delphi调用DLL中的CH375DLL.DLL问题~~(20)

  • 主题发起人 主题发起人 husion
  • 开始时间 开始时间
H

husion

Unregistered / Unconfirmed
GUEST, unregistred user!
type d=array [0..255] of integer; abc:d;Function SetCH372(var x:string):d;stdcall;external 'CH372.dll';Function SetCH372(var x:string):d;stdcall;const mIndex : cardinal=0;var mDemoReq:d; mLength:longword;begin if(CH375ReadData(mIndex,@mDemoReq[0], @mLength))then begin result:=mDemoReq; end;end;代码: ... [red]abc:=SetCH372(x);[/red] ...当程序单步执行到abc:=SetCH372(x);时,发现abc中的值不是单片机发过来的值.比如本来要收到的单片机值是(0,1,2,3)现在变成(19246092752,2,1946092872,0),为什么?谢谢..
 
看看你这两个API声明的对不对String只能在Delphi写的 DLL 中传递DLL和调用程序的第一个以用单元一定要是ShareMem
 
{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. }
 
to iamy:String只能在Delphi写的 DLL 中传递是什么意思?
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
504
import
I
I
回复
0
查看
520
import
I
后退
顶部