In delphi, how do you write a MemoryStream to a data resource?
procedure StringtoRes (filename:string; Inputstream: TMemoryStream);
var
hUpdate: THandle;
begin
hUpdate := BeginUpdateResource(PChar(filename), True);
UpdateResource(hUpdate, RT_RCDATA, 'ID', LANG_NEUTRAL,InputStream,InputStream.Size);
EndUpdateResource(hUpdate,False);
end;
This code gives me an access violation and an intense feeling of inadequancy because I don’t even know where to start fixing it. Does anyone?
In the
lpDataparameter ofUpdateResource(), you need to pass the value of theTMemoryStream.Memoryproperty instead of theTMemoryStreamobject pointer, eg: