假设有一个文本文件,里面有数据1  2
2  3先将该文本文件以资源的形式写到一个dll文件中去,同时dll中定义一个函数,需要调用到上述数据,如何实现?谢谢

解决方案 »

  1.   

    Rc 文件
    txt1 RC_DATA test.txtuses
      SysUtils,
      Classes;{$R *.res}
    {$R inir.res}// dLL 代码
    function GetText(): PChar;
    var
      Str: string;
      Rs: TResourceStream;
    begin
      Rs := TResourceStream.Create(HInstance, 'txt1', 'RC_DATA');
      SetLength(Str, Rs.Size);
      Rs.ReadBuffer(Str[1], Rs.Size);
      Result := PChar(Str);
    end;exports
       GetText;begin
    end.
    调用
    function GetText(): PChar; external 'testdll.dll' name 'GetText';  ShowMessage(GetText);
      

  2.   

    非常感谢假如,test.txt中的数据很多,需要读入到一个数组中进行处理如何操作?先定义一个冬天数组,然后根据行数再确定么?我在建立rc文件时 myfile myres "e:\test.txt"编译时提示:cannot open file e:\test.txt请问怎么回事?
      

  3.   

    刚才发现. e:\test.txt为 e:\test.txt.txt所以导致找不到文件