winapi 声明调用(200分)

  • 主题发起人 主题发起人 netbabys
  • 开始时间 开始时间
N

netbabys

Unregistered / Unconfirmed
GUEST, unregistred user!
VC dll头文件 里 一个这样的函数声明 在DELPHI中如果要调用该如何声明<br>BOOL WINAPI IFInitInterface(<br> DWORD dwCodeProtocol, //编码协议<br> DWORD dwDriverProtocol, //通讯协议<br> LPCTSTR pDriverParam //通讯协议参数<br> );<br>我这样声明,不正确<br>Function IFInitInterface(dwCodeProtecol,dwDriverProtocol:word;pDriverParam:pchar):Boolean;PASCAL ;external 'SMEIDll.dll';
 
1.把word还是换成dword<br>2.不行,把pascal换成stdcall试试<br>3.还不行(应该不会啦)就把pchar试成pointer试试,或者type pch=^char;用pch试试.
 
先看这个API函数属于哪一个函数集,然后在此uses中添加该集合的文件名即可。<br><br>不过一般Delphi都能直接给你加上,不用再声明了。不知是不是我说的这中情况。
 
dword--&gt;long word<br>对要用stdcall<br>
 
请各位注意, BOOL WINAPI IFInitInterface 这里的WINAPI,用STDCALL是不行 c<br>一般的VC 生成 DLL 头文件默认声明如下: <br>----------------------------------<br>#ifdef _C_COMPILER_<br>extern "C"<br>{<br>#endif<br>int CMPPSendSingle(const int nNeedReply, const int nMsgLevel,<br> const char *sServiceID, const int nMsgFormat,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *sMsgID, int *nErrorCode);<br>-------------------<br>以这种方式声明的VC函数在DELPHI里用 ,cdecl 声明 是没有问题的<br>Function CMPPSendSingle(....pchar):integer; cdecl ;external 'SendMSG.dll';<br>是没有问题的<br>不过我再PASICAL 的调用方式试试<br>
 
windows中的API涵数类型在delphi中是可以直接引用的:),因为delphi本身已经有一个<br>pascal版本的API类型声明(如:DWORD),而且在声明一个windowAPI的时候,应该把涵数声明为stdcall<br>这是指明此涵数用标准的参数调用方式:)
 
请问NETBABYS 同志 .这个问题您解决了吗?<br>我能够INITINTERFACE.但是不能够LOGIN_R.您能告诉我吗?<br>ulyssesh@21cn.com 非常感谢.<br>我用STDCALL.执行后程序会挂起30秒.这是为什么.
 
to : ulysses, 此为华为SMPP33 短信API 不过在使用中发现 此API有些问题<br>submit 返回包可能会被 丢失 出错率 &lt;3% 还是比较大的 小范围试用还可以业务大了就不行了<br>如果你有需要我这里有重新写过了 SMPP3.3 协议API 可以共享给你<br>正常网络下 fail 率&lt;0.01% 可以正常接入华为SMPP短信中心 状态报告MT、MO,<br>binary,ascii,unicode发送都支持<br>======================================================================<br>下面为 华为SMPP3.3 API 在 Delphi/Pascal 中的申明<br>Function IFInitInterface( dwCodeProtocol, //编码协议<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwDriverProtocol :longword ; //通讯协议<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pDriverParam :string //通讯协议参数<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;):boolean;stdcall ;external 'CMPPAPI_GD.dll';<br><br>//FALSE表示失败,TRUE表示成功<br>function IFExitInterface():boolean;stdcall ;external 'CMPPAPI_GD.dll';<br><br>//FALSE表示失败,TRUE表示成功<br>function Login_R(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SystemID, //接口名<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Password :string //接口密码<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ):boolean;stdcall ;external 'CMPPAPI_GD.dll';<br><br>//FALSE表示失败,TRUE表示成功<br>function Logout():boolean;stdcall ;external 'CMPPAPI_GD.dll';
 
NETBABYS您好:<br>&nbsp; &nbsp;请问我怎样与你联系。我的联系方法是 ulyssesh@21cn.com<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hongjun@zhenjiangstar.com<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OICQ:780219.<br>&nbsp; 请与我联系。谢谢。
 
接受答案了.
 
后退
顶部