我创建了一个文件.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.谢谢!
发布于 2012-06-06 06:49:06
您可以使用属于LResources单元的TLazarusResourceStream类
尝试此示例
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; https://stackoverflow.com/questions/10905802
复制相似问题