函数原型为:
int __stdcall Cmpp2Start(LPCTSTR pchSmgIp, int nMtPort, int nMoPort,LPCTSTR pchUserName, LPCTSTR pchUserPwd, unsigned char uchVersion,void (__stdcall *OnSmgMsg)(CMPP_SMGTOSP*  css), int nConnType, void (__stdcall *OnLogFile)(LPCTSTR str))
CMPP_SMGTOSP 是个结构。
我的定义是这样的:
  TOnSmgMsg = procedure(css:TCMPP_SMGTOSP) of object;
  TOnLogFile = procedure(str:PAnsiChar) of object;
  TCmpp2Start = function (pchSmgIp:PChar;
                          nMtPort:Integer;
                          nMoPort:Integer;
              pchUserName:PChar;
                          pchUserPwd:PChar;
                          uchVersion:Byte;
                          OnSmgMsg:TOnSmgMsg;
                          nConnType:Integer;
                          OnLogFile:TOnLogFile):Integer;stdcall;
procedure OnSmgMsg(css:TCMPP_SMGTOSP);
begin
    //end;
procedure OnLogFile(str:PChar);
begin
    //
end;但调用的时候却出错了,报E2010 Incompatible types: 'TOnSmgMsg' and 'Pointer'
我的调用是:
Cmpp2Start(PChar('192.168.0.1'),7890,7890,PChar('aa'),Pchar('bb'),Byte(20),@OnSmgMsg,0,@OnLogFile);

解决方案 »

  1.   

    TOnSmgMsg   =   procedure(css:TCMPP_SMGTOSP)   of   object; 
    TOnLogFile   =   procedure(str:PAnsiChar)   of   object; 
    为什么要带of object? 类方法吗?类方法,和一般方法的区别就是,编译的时候,类方法里面会自动增加一个self的参数.
    把of object 去掉试试.另外,后面加stdcall.
      

  2.   

    函数入口是找到了,程序可以运行了。但调用Cmpp2Start的时候还是出错。是不是有些类型用得不正确?
      

  3.   

    unsigned char uchVersion 是应该定义为Byte吗?