LoadResourceToStream function
Return to Introduction  Previous page  Next page
Unit
acUtils  

Declaration
function LoadResourceToStream(Instance: hInst; const ResName, ResType: String;  
    Stream: TStream): Boolean;  

Description
Retrieves resource, specified by name (ResName) and type (ResType) to the Stream.  
 
ResName parameter specifies the name of the resource. If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type. For example, the string '#258' represents the integer identifier 258.  
 
ResType parameter is the string which identifies the type of resource. For standard resource types, this parameter can be one of the following values:  
ValueMeaning  
RT_ACCELERATORAccelerator table  
RT_ANICURSORAnimated cursor  
RT_ANIICONAnimated icon  
RT_BITMAPBitmap resource  
RT_CURSORHardware-dependent cursor resource  
RT_DIALOGDialog box  
RT_FONTFont resource  
RT_FONTDIRFont directory resource  
RT_GROUP_CURSORHardware-independent cursor resource  
RT_GROUP_ICONHardware-independent icon resource  
RT_ICONHardware-dependent icon resource  
RT_MENUMenu resource  
RT_MESSAGETABLEMessage-table entry  
RT_RCDATAApplication-defined resource (raw data)  
RT_STRINGString-table entry  
RT_VERSIONVersion resource  

Example
// Demonstrates custom implementation over LoadResourceToStream  
procedure LoadJPEG(ResourceID: Integer; Picture: TPicture);  
var  
  JPG: TJPEGImage;  
  Stream: TMemoryStream;  
begin  
  JPG := TJPEGImage.Create;  
  try  
    Stream := TMemoryStream.Create;  
    try  
      LoadResourceToStream(hInstance,  
         '#' + IntToStr(ResourceID), 'JPG', Stream);  
      Stream.Seek(0, soFromBeginning);  
      JPG.LoadFromStream(Stream);  
      Picture.Assign(JPG);  
    finally  
      Stream.Free;  
    end;  
  finally  
    JPG.Free;  
  end;  
end;  

See also
ExtractResourceToFile function.