现在有一个.h头文件,有如下声明
#ifndef CMPP_API_H
#define CMPP_API_Htypedef void (FAR PASCAL *LPCMPPRECEIVECALLBACK)(__int64 nMsgIdint);__declspec (dllexport) int SmsInitialize(LPCTSTR lpszIniFileName);
很急啊,多谢各位帮忙

解决方案 »

  1.   

    哦,太急了还没写完,
    如何将以上C++声明转换为delphi的声明,这些函数是在一个dll中实现的
      

  2.   

    type TProcType = procedure (nMsgIdent :Int64);现在不明的是 delphi 调用 dll, 还是用 delphi 写 dll?d 静态调用 dll 可以
    function FuncName(...),...stdcall 定义原形
    实现部分
    function FuncName; external 'DLL name' name 'Function name';d 动态
    动太调入 dll 偶就不说了
    type TProcType = procedure (nMsgIdent :Int64);
    用这定义一函数变量, 强制由 GetProcAddress 反回的指针d 写 DLL就简单了
    procedure xxx; stdcall{必要}; export; {也可以另一种方法}
    {另一种方法}
    export;
      xxx,
      ...;
      

  3.   

    哦,感谢楼上的大虾,还想问
    _int64 *
    LPCSTR *
    bool *
    怎么转换成相应的delphi类型,
    付值的时候又怎么办呢,
    谢了
      

  4.   

    PInt64        = ^Int64;
    PChar (LPCSTR *)
    PBOOL = ^BOOL;
      

  5.   

    #ifndef CMPP_API_H
    #define CMPP_API_H
    还不明白,
    这个C++怎么转换为delphi啊
      

  6.   

    我说的是用delphi调用VC写的dll,现在只有.h头文件,没有.pas声明文件
    全部如下:
    #ifndef CMPP_API_H
    #define CMPP_API_Htypedef void (FAR PASCAL *LPCMPPRECEIVECALLBACK)(__int64 nMsgId, LPCSTR lpszDestnationId,
    LPCSTR lpszServiceId, int nMsgFmt, 
    LPCSTR lpszSrcTermId, LPCSTR lpszMsg, int nMsgLen, bool bReport);__declspec (dllexport) int SmsInitialize(LPCTSTR lpszIniFileName);
    __declspec (dllexport) int SmsTerminate();__declspec (dllexport) int SmsConnect();
    __declspec (dllexport) int SmsDisconnect();__declspec (dllexport) int SmsSendMessage(__int64 *lpnMsgId,
    LPCSTR lpszServiceId, 
    LPCSTR Fee_terminal_id,
    int nMsgFmt, 
    LPCSTR lpszSrcTermId,
    int nDestTermNum,
    LPCSTR *lpDestTermIds,
    LPCSTR lpszMsg, 
    int nMsgLen,
    BOOL bWait);__declspec (dllexport) int SmsSendSingleMessage(__int64 *lpnMsgId,
    LPCSTR lpszServiceId, 
    LPCSTR Fee_terminal_id,
    int nMsgFmt, 
    LPCSTR lpszSrcTermId,
    LPCSTR lpDestTermId,
    LPCSTR lpszMsg, 
    int nMsgLen,
    BOOL bWait);__declspec (dllexport) int SmsReceiveMessage(
    int nTimeout, 
    __int64 *lpnMsgId,
    LPSTR lpsDestnationId,
    LPSTR lpszServiceId,
    int *lpnMsgFmt,
    LPSTR lpszSrcTermId,
    LPSTR lpszMsg,
    int *lpnMsgLen,
    bool *lpbReport);__declspec (dllexport) int SmsActiveTest(BOOL wait);__declspec (dllexport) int SmsSetReceiveCallback(LPCMPPRECEIVECALLBACK lpfnReceiveCallback);#endif
      

  7.   

    #ifndef CMPP_API_H
    #define CMPP_API_H
    上面的意思是如果没有定义这个CMPP_API_H东西,
    就定义这个东西CMPP_API_H。
      

  8.   

    给你翻译一个做例子吧:int SmsConnect();
    int SmsActiveTest(BOOL wait);等价于procedure SmsConnect();cdecl; 
    function SmsActiveTest(nWait: Integer): Integer;cdecl;特别提醒楼主:注意这个调用约定,表示函数按照C语言的方式传递参数,从右到左。不然你会发现调用函数的时候莫名其妙的发生内存错误,找都找不到原因。
      

  9.   

    这个是条件编译
    {$Define ??}
    {$Undef ?}
      

  10.   

    #ifndef CMPP_API_H
    #define CMPP_API_H
    这些编译指令翻译来做什么?不管它就是了。
      

  11.   

    直接用这句久可以,那是c中动态库得声明方式,下边是对应的delphi声明方式!function SmsInitialize(lpszIniFileName:lpchar):integer;far;stdcall;external ;