请教各位前辈:有一Delphi编写Dll
  Delphi中调用如下: 
  function Init; external DLLNAME;  TTraceProc = procedure(Msg: PChar); stdcall;
  TMOProc = procedure(SrcAddr: PChar; Msg: PChar); stdcall;
   function Init(ip: PChar; Port: Word; User: PChar; Pswd: PChar; Queue: PChar; QueueSize: Integer; Trace: TTraceProc; MO: TMOProc): Integer; stdcall;
    C#如何调用? 
        [ DllImport(DLLNAME, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
        public static extern int Init(string ip, ushort Port, string User, string Pswd, string Queue, int QueueSize,???, ???);
      
 

解决方案 »

  1.   

    后面两个是一个代理,你可以试试:public delegate void Traceproc(string message);
    public delegate void MOProc (string srcAdd,string msg);[DllImport(DLLNAME, CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)] 
    public static extern int Init(string ip, ushort Port, string User, string Pswd, string Queue, int QueueSize,Traceproc tp,MOProc mop); 
      

  2.   

    参考一下Windows回调函数的例子(如何传递委托到非托管代码中)
    http://hi.baidu.com/shaic007/blog/item/04da3a54d1874c50574e0017.html