===VC++  ================================================================
#undef LPTSTR
typedef BYTE RSI_ID[5];RSI_DLL RSI_DATA_ERROR RSI_API rsiTextToID(LPCTSTR text, RSI_ID id);
RSI_DLL RSI_DATA_ERROR RSI_API rsiIDToText(RSI_ID id, LPTSTR text);
===Delphi================================================================
Type RSI_ID=record
    b0 : Byte;
    b1 : Byte;
    b2 : Byte;
    b3 : Byte;
    b4 : Byte;
end;
??是不是这样定义Function rsiIDToText(ID:RSI_ID;text:pchar) :RSI_DATA_ERROR; stdcall; external 'rsidll32.dll';
??是不是这样定义Function rsiTextToID(text:pchar;ID:RSI_ID) :RSI_DATA_ERROR; stdcall; external 'rsidll32.dll';===================================================================
rsiIDToText
原形: RSI_DATA_ERROR rsiIDToText(RSI_ID id, LPTSTR text);
参数: RSI_ID id: 一个 BCD 格式的使用者 ID 的数据结构LPTSTR 
          text:一个将会接收使用者 ID 正文字符串的指针
功能: 将一个 BCD 格式的使用者 ID 转换为一个正文格式的使用者 ID
返回: RSI_DATA_OK:成功由 rsiGetDataError 返回的错误值:失败text参数是指针。要怎么定义才行?
===================================================================
这样总是会出现地址错误??
Access violation at address 10039E9 in module 'rsidll21.dll' Read of address 99817489
==============================
var
id:RSI_ID;
str_id:pchar;//??是不是用pchar
begin
Result:= rsiIDToText(ur.ID,str_id);
??rsiIDToText怎样调用呢?
end;
在delphi里要怎样定义和怎样调用呢?

解决方案 »

  1.   

    要注意分配内存,
    建议用shortstring代替pchar,shortstring是256个字符长
    另外,在BCB中不能将传来的字符串等 FREE掉,必须由创建者来释放。
      

  2.   

    type RSI_ID=array[0..5] of char;
    RSI_DLL RSI_DATA_ERROR RSI_API __stdcall rsiTextToID(LPCTSTR text, RSI_ID id);
    RSI_DLL RSI_DATA_ERROR RSI_API __stdcall rsiIDToText(RSI_ID id, LPTSTR text);
      

  3.   

    使用PChar是对的,但是你没有进行内存管理:
    var
      id:RSI_ID;
      str_id:pchar;
    begin
      GetMem(str_id, MAXBYTE);
      Result:= rsiIDToText(ur.ID,str_id);
      FreeMem(str_id);  
    end;—————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    —————————————————————————————————
      

  4.   

    还有应该:
    Type RSI_ID = Array[0..4] of Byte或者Array[0..4] of Char—————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    —————————————————————————————————
      

  5.   

    你的PChar在使用前没有分配内存,所以出现错误,至于RSI_ID,定义成一个结构和一个数组没什么区别。
      

  6.   

    extern "C" __declspec(dellexport) char* PerformReal(char*,char*);
    我的一个DLL里有上面这个函数,在delphi里面该怎么调用?
    我现在是这样声明的:
    function performreal(inum:pchar;s:pchar):pchar;cdecl;external 'name.dll';
    以下我调用
    var 
    num,s:pchar;
    begin
    num:='102';
    s:='12345~asdasda~sdd';
    edit.text:=performreal(num,s);
    end;
    运行的时候提示stack overflow.
    请问我是没有分配内存的缘故吗?该怎么分配啊?