先编写 一个 资源 dll, myres.dpr,如下:library myres;{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } {$R 'myres.res' 'myres.rc'} uses SysUtils, Classes;begin end. 然后创建 vmyres.rc,如下:aaa BITMAP aaa.bmp bbb BITMAP bbb.bmp ccc BITMAP ccc.bmp然后编译 myres.dpr,生成 myres.dll。下面是使用 vmyres.dll:1,加载资源dll:g_ResHandle := LoadLibrary('myres.dll');2, 使用:bmpa, bmpb, bmpc : TBitmap;bmpa.LoadFromResourceName(g_ResHandle, 'aaa'); bmpb.LoadFromResourceName(g_ResHandle, 'bbb'); bmpc.LoadFromResourceName(g_ResHandle, 'ccc');
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
{$R 'myres.res' 'myres.rc'}
uses
SysUtils,
Classes;begin
end.
然后创建 vmyres.rc,如下:aaa BITMAP aaa.bmp
bbb BITMAP bbb.bmp
ccc BITMAP ccc.bmp然后编译 myres.dpr,生成 myres.dll。下面是使用 vmyres.dll:1,加载资源dll:g_ResHandle := LoadLibrary('myres.dll');2, 使用:bmpa, bmpb, bmpc : TBitmap;bmpa.LoadFromResourceName(g_ResHandle, 'aaa');
bmpb.LoadFromResourceName(g_ResHandle, 'bbb');
bmpc.LoadFromResourceName(g_ResHandle, 'ccc');
不过编译到DLL中的办法我知道, 现在我的想法是想用程序直接读取*.res中的资源.
不要将资源编译到exe或者dll中.
如果你想把很多文件做成一个文件供你的程序调用,那自己定义文件格式就成了;
自己定义麻烦的话还可以用各种各样的桌面数据库,总之办法太多了,都比资源文件好