+ -
当前位置:首页 → 问答吧 → 求助 调用dll问题

求助 调用dll问题

时间:2011-10-28

来源:互联网

function EHRSyncTransport( eventid,body: String; var p:pchar ):integer;stdcall;external 'ehradp.dll'



procedure TForm1.Button4Click(Sender: TObject);
var
xmlstr:string;
herder:string;

i:integer;
begin
  //if form3.showmodal=mrok then
 begin
  getmem(x,1000) ;
  OpenDialog1.Execute;

  XMLDocument1.FileName:=OpenDialog1.FileName;
  XMLDocument1.Active:=true;
  xmlStr:= XMLDocument1.XML.Text;
  herder:=copy(xmlstr,pos('<header>',xmlstr), pos('<body>',xmlstr)-51) ; //51消息申明
 xmlstr:=copy(xmlstr,pos('</header>',xmlstr)+9,length(xmlstr)-pos('</header>',xmlstr));
  xmlstr:=copy(xmlstr,0,pos('</body>',xmlstr)+6);
  i:=EHRSyncTransport(herder,xmlstr,p) ;
  showmessage(inttostr(i));
  showmessage(p);
 //else exit;
 end;
 freemem(x) ;
 end;

现在的结果是函数返回值int能取到 但p值没取到 求助

作者: loveme615   发布时间: 2011-10-28

Lz 你这个p是在哪里声明的?哪里赋值的?
函数里var p:pchar 是个指针的指针
感觉应该先分配p的内存,在函数里给他赋值,你才能读到吧

作者: funxu   发布时间: 2011-10-28

public里。。。可能没有赋值。。。这个参数里的返回值要怎么赋值?

作者: loveme615   发布时间: 2011-10-28

我的意思是可能是函数里想要把返回值赋到p里
这个函数代码能看到么?进去看一眼
看不到的话先尝试执行前给p申请空间allocmem;

作者: funxu   发布时间: 2011-10-28