在VC中函数的声明,及参数的定义如下:extern "C" unsigned __declspec(dllexport) __cdecl SendSMS(void *p_DestNo, void *p_SvcType,
    unsigned p_Length, void *p_Content, unsigned char p_TpUid, unsigned char p_TpUdhi,
    void *p_ScheduleTime, unsigned short p_ExpireTime, unsigned short p_Times, unsigned short p_Interval,
    void *p_ChargeNo);
UINT CUsedllDlg::ThreadProc(void* pData)
{  unsigned p_SPCode = 0, p_Length = 0; 
   word p_ExpireTime, p_Times, p_Interval;
   byte  p_TpPid, p_TpUdhi;
   char p_DestNo[22], p_SvcType[11], p_Content[400];
   char p_ScheduleTime[15], p_ChargeNo[22];
   CString tempstr, cs_now;
   int i = 0, j = 0, ii = 0, kk = 0, jj = 0;
   int retcode = 0;
   unsigned char Buffer[4096];
   Receive *rec;
   
   p_SPCode = 100;
   p_ExpireTime = 1440;
   //p_ExpireTime = 5;
   p_Times = 1;
   p_Interval = 0;
   p_TpPid = 0;
   p_TpUdhi = 0;
   memset(p_SvcType, 0, 11);
   memset(p_Content, 0, 400);
   memset(p_ScheduleTime, 0, 15);
   memset(p_ChargeNo, 0, 22);
   memset(p_DestNo, 0, 22);
   sprintf(p_DestNo, "%s", m_pThis->m_DestNum);
   //strcpy(p_SvcType, "ETOTTEST");
   sprintf(p_SvcType, "%s", m_pThis->m_Svr_Type);
   sprintf(p_Content, "%s", m_pThis->m_Content);   
   p_Length = strlen((char*)p_Content); 
CTime ct_now = CTime::GetCurrentTime();
cs_now = ct_now.Format("%Y%m%d%H%M%S"); 
   sprintf(m_pthis->m_destnum,"%s",p_destno); 
   //strcpy(p_ChargeNo, "0");
   sprintf(p_ChargeNo, "%s", m_pThis->m_ChargeNum);   
   m_pThis->m_Flag = 0;
   for(i=0; i<m_pThis->m_Count; i++)
   {
   
   if(m_pThis->m_Flag) return 0;
   int oid = SendSMS(p_DestNo, p_SvcType, p_Length, p_Content, p_TpPid, p_TpUdhi,
 cs_now.GetBuffer(cs_now.GetLength()), p_ExpireTime, p_Times, p_Interval, p_ChargeNo);    
cs_now.ReleaseBuffer();
tempstr.Format("%d",oid);
m_pThis->m_Oid.SetWindowText(tempstr);
能将上面的代码改写成DELPHI电码

解决方案 »

  1.   

    我不知道__declspec(dllexport)的含义,其他的还应该没有什么问题吧
      

  2.   

    回 reedseutozte(haha) SENDSMS是VC DLL库
      

  3.   

    我再msdn上没查到啊Sendsms?
    不过有几个要点可以告诉你
    byte,word再delphi中有定义,你可以简单改一下语法
    char p_DestNo[22]-》p_dest_no:array[1..22] of char;
    Receive是你自己定义的数据类型把
    memset可再delphi中直接用无须改动
    sprintf可以该为format函数
    strlen返回字符串长度,再delphi中也用意实现吧,呵呵
    至于SendSms的调用再pas文件中写类似这样的声明
    function SendSms(.....参数): string(返回类型);
      safecall; external 'XXXX.dll';
      

  4.   

    试试这样写
    procedure SendSMS(p_DestNo:PChar;p_SvcType:PChar;
        p_Length:unsigned;p_Content:PChar;char p_TpUid:unsigned;p_TpUdhi:byte;
        p_ScheduleTime:Pchar; p_ExpireTime:word;p_Times:word; p_Interval:word;
        p_ChargeNo:Pchar);safecall; external 'XXXX.dll';
      

  5.   

    easy!
    4byte数据类型定义为:integer,  1byte数据类型定义为:byte
    字符类型定义为:array [1..22] of char;.....
    p_SvcType:='hello';//赋初直;
    .....
    AStream:=TMemoryString.Create;
    AStream.Write(p_SvcType,6);//字符类型长度为=实际长度+1
    AStream.Write(...,...);
    AStream.Write(...,...);
    AStream.Position:=0;
    ClientSocket1.Socket.SendStream(AStream);
    .....