sizeof()

Auto Hotkey

sizeof

Built in function to calculate size of a structure or type like TCHAR or PTR or VOID..., see also Struct for usage and examples.

OutputVar := sizeof(Definition , offset)
Function Example: sz := sizeof("Uint")

Parameters

OutputVar

The name of the variable in which to store the size of structure or data type.

Definition

You can pass a default data type (e.g. "HANDLE") or structure definition (e.g. "int x,int y") as string or a structure object to retrieve size of a structure.
For a structure object you can also simply call .Size() method.

offset

Offset of preceding structure. Used to calculate correct size and aligns when padding if necessary. This parameter is used internally and is not required to work with structures.

Return Value

Size of structure. If offset was given it will return the new total size of structure (including offset).

Related

Struct, DllCall

Examples

POINT:="UInt x,UInt y"
pt:=Struct(POINT)
MsgBox % sizeof(pt) " = " sizeof(POINT) " = " pt.size()