Delphi中使用资源文件.

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 303 的 blog

目的,在delphi中使用资源文件
本例是将一个flash动画加到我的们程序中,在程序启动时再释放出来.
先新建一个文件文件
写入内容:flash swffile1 thanks.swf
另存为:swffile.rc
然后用brcc32.exe生成资源文件.res
然后在delphi中加入一行(最后一行)
implementation

{$r *.dfm}
{$r swffile.res}//就是这行

然后加一个procedure:

procedure flashrestofile(const resname, restype, filename: string);
var
  flashres: tresourcestream;
begin
  flashres := tresourcestream.create(hinstance, resname, pchar(restype));
  try
    flashres.savetofile(filename); //将资源保存为文件,即还原文件
  finally
    flashres.free;
  end;
end;

使用:
    flashrestofile('flash', 'swffile1', 'thanks.swf');
    shockwaveflash1.movie := extractfilepath(paramstr(0)) + 'thanks.swf';
    shockwaveflash1.play;


本文关键:Delphi中使用资源文件.
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top