Показать сообщение отдельно
  #5  
Старый 25.01.2011, 09:50
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

исходный файл ресурса rc.rc :
Код:
image1 AVATAR "d:\Картинки\Разное\av-37133.jpg"
image2 AVATAR "d:\Картинки\Разное\1190024596_19.jpg"
image3 AVATAR "d:\Картинки\Разное\chel.jpg"
компилим его в rc.RES :
Код:
"c:\Program Files\Borland\Delphi7\Bin\brcc32.exe" rc.rc
Dll:
Код:
library ProjectDll;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes;

{$R *.res}
{$R rc.RES}

begin
end.

ну и сам код по вытаскиванию картинок:
Код:
unit Unit1;

interface

uses
  jpeg,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  HLibrary: HMODULE;

implementation

{$R *.dfm}

procedure ResourceStreamPictureAssign(ResName: String; AImage: TImage);
var
  resourcestream: TResourceStream;
  jpeg: TJPEGImage;
begin
  resourcestream:=TResourceStream.Create(HLibrary, ResName, PChar('AVATAR'));
  jpeg:=TJPEGImage.Create;
  try
    jpeg.LoadFromStream(resourcestream);
    AImage.Picture.Assign(jpeg);
  finally
    jpeg.Free;
    resourcestream.Free;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ResourceStreamPictureAssign('image1', Image1);
  ResourceStreamPictureAssign('image2', Image2);
  ResourceStreamPictureAssign('image3', Image3);
end;

initialization
  HLibrary:=LoadLibrary('ProjectDll.dll');

finalization
  FreeLibrary(HLibrary);

end.
__________________
Пишу программы за еду.
__________________
Ответить с цитированием