C#怎么调用Delphi接口
网上找了很多,都是怎么调用Delphi的函数:
- C# code
[DllImport("SGIPSDK.dll")]static extern ISGIPInterface CreateSGIPInterObject();
就像上面代码,DLL中实现了自定义的接口类型,请问C#中应该怎么声明?
下面是Delphi中的定义
- Delphi(Pascal) code
unit uISGIPInterface;interfaceuses SysUtils,Classes;type //回调接口 IRspSGIPInterface = class(TObject) {/* 启动服务回调 @iRet 0成功,可以开始发送短信 其他注册失败,不能发送短信 @szRspInfo 具体信息 */} procedure OnRspStartService(iRet:Integer; szRspInfo : PChar);virtual;stdcall;abstract; {/* 停止服务回调 @iRet 0成功 @szRspInfo 具体信息 */} procedure OnRspStopService(iRet:Integer; szRspInfo : PChar);virtual;stdcall;abstract; //停止服务回调 {/* 短信回执回调 @szMsgID 消息序号 @szPhonenumber 手机号码 @iState 回执状态 0:发送成功 1:等待发送 2:发送失败 @iErrorCode 错误编号 当iState=2时为错误码值,否则为0 */} procedure OnRspSmsReport(szMsgID : PChar; szPhonenumber : PChar; iState : Integer; iErrorCode : Integer);virtual;stdcall;abstract; //短信回执回调 end; //SGIP封装接口 ISGIPInterface = interface ['{0E11ECF4-694C-4994-A19C-E47D894598A8}'] {/* 启动服务 @lpRsp 回调对象 */} procedure StartService(lpRsp:IRspSGIPInterface);stdcall; //停止服务 procedure StopService;stdcall; {/* 发送短信 @TargetNo 目标手机号 @SmsContent 短信内容(不超过140个字节) @函数返回值 消息序号,-1未启动服务 ,-2未注册成功 */} function SendSMS(const szTargetNo:PChar; const szSmsContent:PChar):PChar;stdcall; end;implementationend.
[解决办法]
这个啊 只能给我转载的 文章了,
仅供参考(only to be reference)
http://blog.csdn.net/jason_dct/article/details/7493755
[解决办法]
楼上的例子很详细了