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提示沒初始化,,怎么初始化
uj5u.com熱心網友回復:
varstr:string;
Result:=str;
堆疊中的變數那來做回傳值! 程序結束也就被釋放了!
uj5u.com熱心網友回復:
不是很明白,, 我的想法是 外部通過傳入byte陣列,通過delphi讀入流,轉化成特定格式,回傳去,deiphi必須用到TRichViewEdit控制元件,這個控制元件警告要初始化
uj5u.com熱心網友回復:
你是VAR 定義啊 要CREATE 的uj5u.com熱心網友回復:
還可以這么定義那,,,就是要初始化,,但是RichViewEdit的建構式要傳入引數 Tcompenent型別的,所以不知道怎么做了,,uj5u.com熱心網友回復:
.net沒有對應于delphi的string型別,不要光看名字相同。uj5u.com熱心網友回復:
菜到極致了,RVE := TRichViewEdit.Create
不應該回傳字串,而是回傳字串的長度,字串存到接收的緩沖區中
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/108828.html
標籤:語言基礎/算法/系統設計
下一篇:關于編碼問題?
