Return to Snippet

Revision: 29645
at August 2, 2010 18:04 by icebob


Initial Code
procedure ExtractResource(ResourceName, FileName: string);
begin
  ExtractResource(hInstance, ResourceName, Filename);
end;
procedure ExtractResource(hnd: Cardinal; ResourceName, FileName: string);
var
 rStream: TResourceStream;
 fStream: TFileStream;
begin
  if FindResource(hnd, PChar(ResourceName), RT_RCDATA) <> 0 then
  begin
    rStream := TResourceStream.Create
             (hnd, ResourceName, RT_RCDATA);
    try
      fStream := TFileStream.Create(FileName, fmCreate);
      try
       fStream.CopyFrom(rStream, 0);
      finally
        fStream.Free;
      end;
    finally
      rStream.Free;
    end;
  end;
end;

Initial URL

                                

Initial Description

                                

Initial Title
Extract a resource to file

Initial Tags

                                

Initial Language
Delphi