涉及指针类型api函数的delphi声明问题(50分)

  • 主题发起人 主题发起人 张鸿林
  • 开始时间 开始时间

张鸿林

Unregistered / Unconfirmed
GUEST, unregistred user!
对c++不熟,因此有这个问题:<br>api的相关声明:<br>1。typedef struct _RAPIINIT { <br>DWORD cbSize; <br>HANDLE heRapiInit; <br>HANDLE hrRapiInit; <br>} RAPIINIT; <br>2。CeRapiInitEx <br>HRESULT CeRapiInitEx(<br>RAPIINIT* pRapiInit );<br>我在delphi如此声明:<br>Type<br>&nbsp; RAPIINIT=packed record<br>&nbsp; &nbsp; cbsize : integer;<br>&nbsp; &nbsp; heRapiInit: integer;<br>&nbsp; &nbsp; hrRapiInit: integer;<br>&nbsp; end ;<br>&nbsp; PRAPIINIT =^RAPIINIT;<br>Function CeRapiInitEx(pRapiInit : PRAPIINIT):integer;<br>实现:<br>Function CeRapiInitEx(pRapiInit : PRAPIINIT):integer; external 'rapi.dll';<br><br>调用的代码:<br>Function ConnectRapi:integer;<br>var lcon :integer;<br>&nbsp; &nbsp; lRapiInit:RAPIINIT;<br>begin<br>&nbsp; &nbsp; With lRapiInit do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; cbsize := SizeOf(lRapiInit) ;<br>&nbsp; &nbsp; &nbsp; &nbsp; heRapiInit := 0 ;<br>&nbsp; &nbsp; &nbsp; &nbsp; hrRapiInit := 0 ;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; lcon := CeRapiInitEx(@lRapiInit) ; &nbsp;//在这里出现access vialation at address XXXXXXXXXXX<br>&nbsp; &nbsp; result:=lcon ;<br>end;<br>
 
知道了,不该没想到的错误,delphi声明需加stdcall关键字,如下<br>Function CeRapiInitEx(pRapiInit : PRAPIINIT):integer;stdcall;
 
谁来跟贴一下,好让我把题结掉
 
接受答案了.
 

Similar threads

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