delphi下调用vc写的dll,请帮忙看看(100分)

  • 主题发起人 主题发起人 Gloomymoon
  • 开始时间 开始时间
G

Gloomymoon

Unregistered / Unconfirmed
GUEST, unregistred user!
dll的定义如下:<br>typedef struct LOCATE_RET<br>{<br> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x;<br> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;y;<br> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deviation;<br> int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; areaID;<br>}LOCATE_RET, *PLOCATE_RET;<br>//exported functions<br>RSSIAPI_API &nbsp; int &nbsp;fnDataCollect(double x, double y, int direction, int repeat);<br>RSSIAPI_API &nbsp; int &nbsp;fnRequestLocate(int repeat, int avgtimes);<br>RSSIAPI_API &nbsp; int &nbsp;fnGetLocateResult(LOCATE_RET * locate);<br>RSSIAPI_API &nbsp; bool fnInitService(LPSTR serverip, LPSTR localip, int deviceIndex);<br><br>请教delphi下要怎么写?
 
没人看吗?
 
我也想知道!!
 
静态调用:<br>function fnDataCollect(x:double; y:double; direction:integer; repeat:integer):integer;cdecl; external '****.dll';<br>function fnRequestLocate(repeat:integer; avgtimesinteger:integer);integer;cdecl; external '****.dll';<br><br>另外定义一个vc里面一样的结构<br>.......
 
把VC中的类型转换为Delphi中的,才可以调用。
 
type <br>&nbsp;LOCATE_RET= TLOCATE_RET;<br>&nbsp;PLOCATE_RET=^TLOCATE_RET; <br>&nbsp;TLOCATE_RET= record<br>&nbsp;double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x;<br>&nbsp;double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;y;<br>&nbsp;double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deviation;<br>&nbsp;integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; areaID;<br>end;<br>export<br>&nbsp; function fnDataCollect(double x, double y, int direction, int &nbsp; repeat) :integer,<br>&nbsp; function fnRequestLocate(int repeat, int avgtimes) :integer,<br>&nbsp; function fnGetLocateResult(LOCATE_RET * locate) :integer,<br>&nbsp; function fnInitService(LPSTR serverip, LPSTR localip, int deviceIndex) :boolean;<br><br>
 
我觉得问题是记录类型的转换<br>在delphi里面分配内存,将指针返回给dll里的函数,而dll是用c写的,这样会出错<br>不知道有没有好的办法?
 
后退
顶部