{ following code is copied directly from Assarbad }
function putbinresto(binresname:
string; path:
string): boolean;
var ResSize, HG, HI, SizeWritten, hFileWrite: Cardinal;
begin
result := false;
//find resource
HI := FindResource(hInstance, @binresname[1], '
BINRES');
//if legal handle, go on
if HI <> 0
then
begin
//load resource and check the handle
HG := LoadResource(hInstance, HI);
if HG <> 0
then
begin
//check resource size (needed to copy a block of data)
ResSize := SizeOfResource(hInstance, HI);
//create the file
hFileWrite := CreateFile(@path[1], GENERIC_READ
or GENERIC_WRITE,
FILE_SHARE_READ
or FILE_SHARE_WRITE,
nil, CREATE_ALWAYS,
FILE_ATTRIBUTE_ARCHIVE, 0);
//if succeeded ...
if hFileWrite <> INVALID_HANDLE_VALUE
then
try
//write to it
result := (WriteFile(hFileWrite, LockResource(HG)^, ResSize,
SizeWritten,
nil)
and (SizeWritten = ResSize));
finally
//close file
CloseHandle(hFileWrite);
end;
end;
end;
end;