I\'m a bit puzzled as to how Pointers should be properly used in my scenario. I have a DLL with some embedded resources in it. I expose a function in this DLL which passes binar
Another way passing the stream from a DLL to the application could be using interfaced streams.
implementation
uses MemoryStream_Interface;
{$R *.dfm}
Type
TGetStream = Procedure(var iStream:IDelphiStream);stdcall;
procedure TForm1.Button1Click(Sender: TObject);
var
h:THandle;
p:TGetStream;
ms :IDelphiStream;
j:TJpegImage;
begin
ms := TInterfacedMemoryStream.Create;
h := LoadLibrary('ShowStream.dll');
if h <> 0 then
try
@p := GetProcAddress(h,'GetJpegStream');
p(ms);
ms.Position := 0;
j := TJpegImage.create;
Image1.Picture.Assign(j);
j.Free;
Image1.Picture.Graphic.LoadFromStream(TInterfacedMemoryStream(ms));
finally
FreeLibrary(h);
end;
end;
The code for IDelphiStream can be found on http://www.delphipraxis.net.
I won't copy the content of MemoryStream_Interface to this post, because there are no copyright informations on the code from the mentioned page.