Load bitmap from resource DLL

Posted in Resource

First of all, you should load the library with LoadLibrary function. And for loading bitmap from this library use LoadFromResourceName function. There is a 'BITMAP3' section which contents a bitmap file in the resource file.

procedure TForm1.Button1Click(Sender: TObject);
var
  LibHandle: THandle;
  Bitmap: Tbitmap;
begin
  LibHandle:=Loadlibrary('MyDLL.dll');
  try
    if LibHandle<>0 then
    begin
      Bitmap:=TBitmap.Create;
      Bitmap.LoadFromResourceName(LibHandle,'BITMAP3');
      Image1.Canvas.Draw(0,0,Bitmap);
    end;
  finally
    Bitmap.Free;
  end;
end;