ResourceStream#

Qualified name: delphivcl.ResourceStream

class ResourceStream#

Bases: CustomMemoryStream

TResourceStream is a memory stream that provides access to the compiled resources in an application. Use TResourceStream to read the resources of an application. An instance of TResourceStream holds the value of a single resource in a memory buffer where it is accessible to the application. The global ReadComponentRes function uses TResourceStream to access the compiled resources used by the application.

Methods

Create

Creates an instance of TResourceStream associated with a particular resource name and type.

CreateFromID

<Delphi method CreateFromID of type TResourceStream at 21141124060>

Destroy

Destroys an instance of TResourceStream.

Free

Frees the Wrapped Delphi Object

InheritsFrom

Returns True if Delphi Object is or inherits from ClassName

ReadBytes

Read content as bytes.

ReadFloat

Read content as float.

ReadInt

Read content as integer.

ReadString

Read content as string.

SetProps

Sets several properties in one call

ToList

If the object is a container (TStrings, TComponent...), it returns the content of the sequence as a Python list object.

ToTuple

If the object is a container (TStrings, TComponent...), it returns the content of the sequence as a Python tuple object.

Write

Overrides the inherited method to raise an exception when an attempt is made to write the resource back to the application.

WriteBytes

Write content as bytes.

WriteFloat

Write content as float.

WriteInt

Write content as integer.

WriteString

Write content as string.

Attributes

ClassName

Returns the TObject.ClassName

Memory

Provides direct access to the memory pool allocated for the memory stream.

Position

Indicates the current offset into the stream for reading and writing.

Size

Indicates the size in bytes of the stream.

ClassName#

Returns the TObject.ClassName

Create(Instance: NativeUInt, ResName: string, ResType: PWideChar)#

Creates an instance of TResourceStream associated with a particular resource name and type. Call Create to instantiate a TResourceStream, passing in parameters that identify the resource in a specified instance. TResourceStream finds the resource data and loads it into the Memory buffer for the TResourceStream. The Instance parameter is the instance handle associated with the executable or shared library that contains the resource. In the first constructor syntax, the ResName is the string associated with the resource in the .rc file that was compiled with the application. If the resource is associated with an integer ID rather than a string, use the string representation of the integer after a pound sign. Thus, for example, a resource with an integer identifier of 128 be identified by a ResName of #128.

Note: Specifying resources by ID requires less memory than specifying resources by name. The ResType parameter is a string identifying the type of the resource. Applications can define their own resource types and identify them by name in the .rc file. In addition, there are a number of predefined resource types (which reflect Windows resource types). To identify a resource that is one of the predefined resource types, set ResType to the appropriate value from the following table:

ResType

Type of resource

RT_ACCELERATOR

Accelerator table

RT_BITMAP

Bitmap resource

RT_DIALOG

Dialog box

RT_FONT

Font resource

RT_FONTDIR

Font directory resource

RT_MENU

Menu resource

RT_RCDATA

Application-defined resource (raw data)

RT_STRING

String-table entry

RT_MESSAGETABLE

Message-table entry

RT_CURSOR

Hardware-dependent cursor resource

RT_GROUP_CURSOR

Hardware-independent cursor resource

RT_ICON

Hardware-dependent icon resource

RT_GROUP_ICON

Hardware-independent icon resource

RT_VERSION

Version resource

CreateFromID(Instance: NativeUInt, ResID: Integer, ResType: PWideChar)#

<Delphi method CreateFromID of type TResourceStream at 21141124060>

Destroy()#

Destroys an instance of TResourceStream. Do not call Destroy directly in an application to destroy an instance of TResourceStream. Instead, call Free. Free verifies that the TResourceStream reference is not nil, and only then calls Destroy. Destroy frees the memory buffer that stores the resource before calling the inherited destructor.

Free()#

Frees the Wrapped Delphi Object

InheritsFrom(ClassName)#

Returns True if Delphi Object is or inherits from ClassName

ReadBytes()#

Read content as bytes.

ReadFloat()#

Read content as float.

ReadInt()#

Read content as integer.

ReadString()#

Read content as string.

SetProps(prop1=val1, prop2=val2...)#

Sets several properties in one call

ToList()#

If the object is a container (TStrings, TComponent…), it returns the content of the sequence as a Python list object.

ToTuple()#

If the object is a container (TStrings, TComponent…), it returns the content of the sequence as a Python tuple object.

Write(Buffer, Count: Integer) Integer#

Overrides the inherited method to raise an exception when an attempt is made to write the resource back to the application. Applications should not use a TResourceStream to write the resources of the running application. Write overrides the inherited method to raise an EStreamError exception when an application tries to write to the application’s resources. As all other data-writing methods of TResourceStream (WriteBuffer, WriteComponent) call Write to do the actual writing, calling any of the data-writing methods of TResourceStream will raise an exception.

WriteBytes()#

Write content as bytes.

WriteFloat()#

Write content as float.

WriteInt()#

Write content as integer.

WriteString()#

Write content as string.