加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 提取lazarus资源

发布时间:2020-12-14 03:52:28 所属栏目:Windows 来源:网络整理
导读:我创建了一个文件.Lrs和我导入到程序中,它可以工作,但是如何从程序中获取资源并将其解压缩到我的PC上的某个位置?这是代码: unit Unit1; {$mode objfpc}{$H+}interfaceuses Classes,SysUtils,FileUtil,Forms,LResources,Controls,Graphics,Dialogs,ExtCtrls
我创建了一个文件.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.

谢谢!

解决方法

您可以使用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:Fooimage.png');
   finally
     Stream.Free;
   end;
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读