提取拉撒路资源

时间:2012-06-05 22:20:39

标签: windows delphi resources extract lazarus

我创建了一个文件.Lrs和我导入到程序中,它可以工作,但是如何从程序中获取资源并将其解压缩到我的PC上的某个位置?这是代码:

unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, LResources, Controls, Graphics, Dialogs, ExtCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

initialization
{$I resource.lrs}

end.

谢谢!

1 个答案:

答案 0 :(得分:5)

您可以使用属于TLazarusResourceStream单元

LResources

试试这个样本

var
  Stream: TLazarusResourceStream;
begin
  Stream := nil;
  try
    //load the lazarus resource  
    Stream := TLazarusResourceStream.Create('image', nil);
    //save to a file
    Stream.SaveToFile('C:\Foo\image.png');
   finally
     Stream.Free;
   end;
end;