在程序中使用资源文件:
在DOS下:
copy con aa.rc <cr>
a1 string d:/aa.txt
a2 string d:/bb.txt
<F6><Cr>
这样就生成了aa.rc
C:/Program Files/Borland/Delphi4/Bin/brcc32.exe aa.rc
成生aa.res
如何在程序中调用呢?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Ptrtxt : PChar;
hRes : THandle;
implementation
{$R d:/aa.res}
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var hResInfo : THandle;
bb:string;
begin
bb:='a1';
hResInfo := FindResource(HInstance, pchar(bb), 'string');
hRes := LoadResource(HInstance, hResInfo);
if hRes > 32 then {its a good load}
begin //锁定资源
ptrtxt:=LockResource(hRes);
end;
showmessage(ptrtxt);
end;
end.