library RtfString;{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }
uses
  Windows,SysUtils,Classes,Forms, RichView,  RVEdit,  RVStyle;
   type r=Array Of byte;
function ReadRtfString(var cbytes:Array Of byte):string;stdcall;
var sm:TMemoryStream;
   RVE: TRichViewEdit;
   rtf:r;
   str:string;
begin     sm:=TMemoryStream.create;
     sm.SetSize(Sizeof(cbytes));
     sm.WriteBuffer( cbytes,Sizeof(cbytes));     RVE.LoadRVFFromStream(sm);
     RVE.Format;
     sm.Clear;
     RvE.SaveRTFToStream(sm,true);
     sm.ReadBuffer(rtf,sm.Size);
     Move(rtf[0],str[1], Length(rtf));
     Result:=str;
end;exports
ReadRtfString index 1;begin
end.
这段代码写来共.net调用,,,RVE提示没初始化,,怎么初始化

解决方案 »

  1.   

    var
       str:string;
     
    Result:=str;栈中的变量那来做返回值! 过程结束也就被释放了! 
      

  2.   

    不是很明白,, 我的想法是 外部通过传入byte数组,通过delphi读入流,转化成特定格式,返回去,deiphi必须用到TRichViewEdit控件,这个控件警告要初始化
      

  3.   

    还可以这么定义那,,,就是要初始化,,但是RichViewEdit的构造函数要传入参数 Tcompenent类型的,所以不知道怎么做了,,
      

  4.   

    .net没有对应于delphi的string类型,不要光看名字相同。
      

  5.   

    菜到极致了,
    RVE := TRichViewEdit.Create
    不应该返回字符串,而是返回字符串的长度,字符串存到接收的缓冲区中