[Overview][Resource strings][Constants][Types][Classes][Index] Reference for unit 'resource' (#fcl-res)

TResources.LoadFromFile

Loads the contents of the object from a file

Declaration

Source position: resource.pp line 269

public procedure TResources.LoadFromFile(

  aFileName: string

); overload;

procedure TResources.LoadFromFile(

  aFileName: string;

  aReader: TAbstractResourceReader

); overload;

Arguments

aFileName

  

The name of file to read from

Arguments

aFileName

  

The name of file to read from

aReader

  

The reader to use to read the file

Description

This method clears the TResources object and loads its contents from the file passed as parameter.

If a reader is specified, that reader is used. Otherwise, the file is probed to find a suitable reader.

Remark: If CacheData is set to true, the file will be left open and used as the underlying stream of each resource RawData stream. This means that the file will be open until the TResources object is cleared or is loaded again from a different source. If you want the file to be closed while there are still resources, disable the copy-on-write mechanism by setting CacheData property to false.

Sample code

This code extracts resources from an exe file

var
  resources : TResources;
begin
  resources:=TResources.Create;
  resources.LoadFromFile('myexe.exe');
  resources.WriteToFile('myexe.res');
  resources.Free;
end;

Errors

If no reader is passed and probing fails, an EResourceReaderNotFoundException exception is raised.

See also

TAbstractResourceReader

  

Base abstract resource reader class

TAbstractResource.RawData

  

The raw resource data stream

TAbstractResource.CacheData

  

Controls the copy-on-write behaviour of the resource

TResources.CacheData

  

Controls the copy-on-write behaviour of all resources

TResources.LoadFromStream

  

Loads the contents of the object from a stream

TResources.Clear

  

Deletes all resources

TResources.FindReader

  

Searches for a suitable resource reader


Documentation generated on: Nov 14 2015