{Ex Binder v0.1
Just an example of using Resources to bind multiple files into
a single executable.
Author: TM
}
unit untMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TfrmMain =
class(TForm)
BtnOpen1: TButton;
Bevel1: TBevel;
BtnBuild: TButton;
OD: TOpenDialog;
LstFile: TListBox;
procedure BtnOpen1Click(Sender: TObject);
procedure BtnBuildClick(Sender: TObject);
procedure LstFileDblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.BtnOpen1Click(Sender: TObject);
begin
if OD.Execute
then
LstFile.Items.Add(OD.FileName);
end;
procedure TfrmMain.BtnBuildClick(Sender: TObject);
var
I:Integer;
H, Size, FH, BR:DWORD;
Local:
String;
Buf:Pointer;
begin
Local:= ExtractFilePath(ParamStr(0));
CopyFile(PChar(
Local+'
Stub\Stub.exe'), PChar(
Local+'
Out.exe'), False);
H:= BeginUpdateResource(PChar(
Local+'
Out.exe'), True);
for I:= 0
to LstFile.Items.Count-1
do begin
FH:= CreateFile(PChar(LstFile.Items[I]), GENERIC_READ, FILE_SHARE_READ,
nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
Size:= GetFileSize(FH,
nil);
GetMem(Buf, Size);
ReadFile(FH, Buf^, Size, BR,
nil);
CloseHandle(FH);
UpdateResource(H, RT_RCDATA, PChar(UpperCase(ExtractFileName(LstFile.Items[I]))), MAKEWord(LANG_NEUTRAL, SUBLANG_NEUTRAL), Buf, Size);
FreeMem(Buf);
end;
EndUpdateResource(H, False);
end;
procedure TfrmMain.LstFileDblClick(Sender: TObject);
begin
if LstFile.ItemIndex <> -1
then
LstFile.Items.Delete(LstFile.ItemIndex);
end;
end.