目的,在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;