Home > Back-end >  Perfect, very simple
Perfect, very simple

Time:10-03

The library RtfString;

{Important note about DLL memory management: ShareMem must be the
The first unit in your library 's USES clause AND your project' s (select
The Project - the View Source) USES clause if your DLL exports any procedures or
Functions provides 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 get the using BORLNDMM. DLL, pass the string information
Using PChar or ShortString parameters.}
USES the
Windows, SysUtils, Classes, Forms, RichView, RVEdit, RVStyle;
The type r=an Array Of byte;
The function ReadRtfString (var cbytes: an Array Of byte) : string; Stdcall;
Var sm: TMemoryStream;
RVE: TRichViewEdit;
The RTF: r;
STR: string;
The begin

Sm:=TMemoryStream. Create;
Sm. SetSize (Sizeof (cbytes));
Sm. WriteBuffer (cbytes, Sizeof (cbytes));

RVE. LoadRVFFromStream (sm);
RVE. Format;
Sm. The Clear;
RvE. SaveRTFToStream (sm, true);
Sm. ReadBuffer (RTF, sm. Size);
Move (RTF [0], STR [1], the Length (RTF));
Result:=STR;
end;

Exports
ReadRtfString index 1;

The begin
End.
This code is written to a total of.net calls, RVE suggest not initialize,, how to initialize

CodePudding user response:

Var
STR: string;

Result:=STR;

Stack variables in the return value to do! Will be released from the end of the process as well.

CodePudding user response:

reference 1st floor xhz8000 response:
var
STR: string;

Result:=STR;

Stack variables in the return value to do! Will be released from the end of the process as well.

Is not very understand,, my idea is external through incoming byte array, read through the Delphi inflow, into a specific format, to return, deiphi must use TRichViewEdit controls, this control warning to initialize

CodePudding user response:

Are you a VAR definition to CREATE

CodePudding user response:

reference yc515623876 reply: 3/f
VAR definition is you want to CREATE
can also be defined so that,,, is to initialize,, but RichViewEdit constructor to incoming parameters Tcompenent type, so I don't know how to do it,,

CodePudding user response:

.net is not corresponding to the Delphi string type, don't just see the same name,

CodePudding user response:

Food to the extreme,
RVE:=TRichViewEdit. The Create
Should not return a string, but returns the length of the string, the string in the receive buffer