原C++代码: int SS_Send_String(const int addr,const int Width,const int Height, const int Effect,
            const int Speed,const int Delay,const int Color,const char *DataString)
改DELPHI: function SS_Send_String(addr:integer;Width:integer;Height:integer; Effect:integer; Speed:integer; Delay:integer; Color1:integer; DataString:pchar):integer;stdcall;external 'pTpSend.dll';
运行时出错! 

解决方案 »

  1.   

    C++中的const char *DataString是const类型,估计是先初始化了的,你的DataString:pchar传递过去时,初始化了吗,分配内存了吗,设置长度了吗?
    最好也设置下delphi中形参为const
      

  2.   

    function SS_Send_String(addr:integer;Width:integer;Height:integer; Effect:integer; Speed:integer; Delay:integer; Color1:integer; DataString:pchar):integer;cdecl;external 'pTpSend.dll'; 
      

  3.   

    把你调用DLL时的代码与出错信息贴出来
      

  4.   

    在程序运行时出错!  错误信息: 无法定位程序输入点 SS_Send_String 于动态链接库 pTpSend.dll 上.
    在BC++ 调用是正常的.
      

  5.   

    原C代码:
    {int ret;
        AnsiString  str;    str = this->Edit1->Text;
        this->Caption = "......";
        Application->ProcessMessages();
        HINSTANCE Hinst = NULL;
        try
        {
            Hinst = LoadLibrary(dllfile.c_str());
            if(Hinst)
            {
                SS_Open_Com_PDJ = (TSS_Open_Com_PDJ *)GetProcAddress(Hinst,"SS_Open_Com_PDJ");
                SS_Close        = (TSS_Close        *)GetProcAddress(Hinst,"SS_Close");
                SS_Send_String  = (TSS_Send_String  *)GetProcAddress(Hinst,"SS_Send_String");
                if(SS_Send_String!=NULL && SS_Close!=NULL && SS_Open_Com_PDJ!=NULL)
                {
                    ret = SS_Open_Com_PDJ(cmbComPort->ItemIndex,cmbRate->ItemIndex,cseDelay->Value);
                    if(ret==0)
                    {
                        ret = SS_Send_String(cseAddress->Value,cseWidth->Value,cseHeight->Value,cmbEffect->ItemIndex+1,
                              cseSpeed->Value,csePlayDelay->Value,cmbColor->ItemIndex,str.c_str());
                        SS_Close();
                    }
                }
                else ret = -1;
                FreeLibrary(Hinst);
            }
        }
        catch(...)
        {
            ret = -2;
        }
        this->Caption = "Ret: " + IntToStr(ret);
    }
    ---- 我有DELPHI 代码:
    var D: integer;
        DLLHandle: THandle;
        SS_Open_Com: TSS_Open_Com;
        SS_Close: TSS_Close;
        SS_Send_String: TSS_Send_String;
    begin
        DLLHandle := LoadLibrary('pTpSend.dll');    try        @SS_Open_Com := GetProcAddress(DLLHandle, 'SS_Open_Com');
            @SS_Close := GetProcAddress(DLLHandle, 'SS_Close');
            @SS_Send_String := GetProcAddress(DLLHandle, 'SS_Send_String');
            if (Assigned(@SS_Open_Com)) and (Assigned(@SS_Close)) then        begin
                SS_Open_Com(0, 9600, 5);
                D := SS_Send_String(1, 80, 32, 1, 1, 5, 0, pchar(Edit1.Text));
                SS_Close;
            end;
            Edit2.Text := FloatToStr(D);
            FreeLibrary(DLLHandle);    finally        FreeLibrary(DLLHandle);    end;----- 没有返回
      

  6.   

    SS_Open_Com_PDJ = (TSS_Open_Com_PDJ *)GetProcAddress(Hinst,"SS_Open_Com_PDJ"); @SS_Open_Com := GetProcAddress(DLLHandle, 'SS_Open_Com'); 怎么打开串口的函数名称不一样?