|
LoadResourceToStream function
|
|
| acUtils
|
| function LoadResourceToStream(Instance: hInst; const ResName, ResType: String;
|
| Stream: TStream): Boolean;
|
| 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:
|
| Value | Meaning
|
| RT_ACCELERATOR | Accelerator table
|
| RT_ANICURSOR | Animated cursor
|
| RT_ANIICON | Animated icon
|
| RT_BITMAP | Bitmap resource
|
| RT_CURSOR | Hardware-dependent cursor resource
|
| RT_DIALOG | Dialog box
|
| RT_FONT | Font resource
|
| RT_FONTDIR | Font directory resource
|
| RT_GROUP_CURSOR | Hardware-independent cursor resource
|
| RT_GROUP_ICON | Hardware-independent icon resource
|
| RT_ICON | Hardware-dependent icon resource
|
| RT_MENU | Menu resource
|
| RT_MESSAGETABLE | Message-table entry
|
| RT_RCDATA | Application-defined resource (raw data)
|
| RT_STRING | String-table entry
|
| RT_VERSION | Version resource
|
| // 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;
|
| ExtractResourceToFile function.
|