wenn du schon TStreamAdapter verwendest, dann übergib doch ne interfacereferenz. TStreamAdapter implementiert IStream, damit kannst du dann in der
DLL herrvorragend arbeiten
mal so aus der hüfte geschossen
Delphi-Quellcode:
procedure TForm2.Button1Click(Sender: TObject);
type
Tp=Procedure(
const s: IStream);
var
ms:TMemoryStream;
isa:IStream;
s:
String;
h:THandle;
p:
Tp;
begin
s :='
Nur ein Test ohne weiteren Sinn';
ms := TMemoryStream.Create;
isa:=TStreamAdapter.Create(ms, soOwned);
try
ms.
Write(s[1],Length(s) * SizeOf(Char));
h := LoadLibrary('
ShowStream.dll');
if h <> 0
then
try
@p := GetProcAddress(h,'
ShowAStream');
p(isa);
finally
FreeLibrary(h);
end;
finally
isa :=
nil;
end;
end;
____________________________________________________
library ShowStream;
uses
SysUtils,
Classes,
Dialogs,
ActiveX;
{$R *.res}
Procedure ShowAStream(
const isa:IStream);
var
s:
String;
StatStg: TStatStg;
StatFlag: LongInt;
lPos: Int64;
pRead; PLongInt;
begin
ms:=TMemoryStream.Create;
try
isa.stat(StatStg, StatFlag);
setlength(s, StatStg.cbSize);
isa.Seek(0, soFromBeginngin, lPos);
isa.
Read(PChar(s), StatStg.cbSize, pRead);
Showmessage(s);
finally
ms.Free;
end;
end;
Exports
ShowAStream
index 1;
begin
end.