Hi there,

first concerning the example: it executes a BAT script contained as "BINRES"
resource type. the file is extracted to C:\Test.bat. It is once extracted from
the included DLL and once from the EXE itself.

well the parameters now described ... see the code below.

--------------------------------------------------------------------------------
function ExtractResTo(Instance: hInst; BinResName, NewPath, ResType: string):
  boolean;
(*******************************************************************************
 Function:   ExtractResTo
 Returns:    Boolean (true=success)
 Version:    Function version 3.0

 Parameters
 Instance:   is the instance handle of the module containing the resource. if not
             current module, use LLoadLibrary() and FreeLibrary() to load and free
             the module containing the resource.
 BinResName: is the name of the resource to extract. this would even work with
             icons, cursors, texts, yaddayadda ...
 NewPath:    path of the file to create from the resource (where to put the
             file)
 ResType:    resource type. pre-defined values can be found in Windows.pas
             e.g. RT_RCDATA
 *******************************************************************************)
var
  ResSize,
    HG,
    HI,
    SizeWritten,
    hFileWrite: Cardinal;
begin
  result := false;
  HI := FindResource(Instance, @binresname[1], @ResType[1]);
  if HI <> 0 then begin
    HG := LoadResource(Instance, HI);
    if HG <> 0 then
    try
      ResSize := SizeOfResource(Instance, HI);
      hFileWrite := CreateFile(@newpath[1], GENERIC_READ or GENERIC_WRITE,
        FILE_SHARE_READ or FILE_SHARE_WRITE, nil, CREATE_ALWAYS,
        FILE_ATTRIBUTE_ARCHIVE, 0);
      if hFileWrite <> INVALID_HANDLE_VALUE then
      try
        result := (WriteFile(hFileWrite, LockResource(HG)^, ResSize,
          SizeWritten, nil) and (SizeWritten = ResSize));
      finally
        CloseHandle(hFileWrite);
      end;
    except;
    end;
  end;
end;
--------------------------------------------------------------------------------

