Hi I have a program that when a button is loaded, creates a resource manually in the application itself (in this case an image) and then reads the resource to display in a timage.El problem is that it seems that creates the resource well but when I want load the resource says it can not find it when you are looking for.
The code.
procedure StringtoRes(const FileName: string; Inputstream: TMemoryStream);
var
hUpdate: THandle;
begin
hUpdate := BeginUpdateResource(PChar(FileName), True);
try
UpdateResource(hUpdate, RT_RCDATA, 'ID', LANG_NEUTRAL, Inputstream.Memory,
Inputstream.Size);
finally
EndUpdateResource(hUpdate, False);
end;
end;
procedure TForm1.btnTestClick(Sender: TObject);
var
MemStr: TMemoryStream;
FileName: string;
var
RStream: TResourceStream;
JPEGImage: TJPEGImage;
begin
FileName := 'c:/test/test.jpg';
MemStr := TMemoryStream.Create;
MemStr.LoadFromFile(FileName);
MemStr.Seek(0, soFromBeginning);
StringtoRes(paramstr(0), MemStr);
MemStr.Free;
Sleep(3000);
RStream := TResourceStream.Create(HInstance, 'ID', RT_RCDATA);
JPEGImage := TJPEGImage.Create;
JPEGImage.LoadFromStream(RStream);
Image1.Picture.Graphic := JPEGImage;
JPEGImage.Free;
RStream.Free;
end;
as I solve this?