Name
TGUID Type
Syntax
type TGUID = packed record D1: LongWord; D2: Word; D3: Word; D4: array[0..7] of Byte; end;
Description
The TGUID
type stores a Globally Unique Identifier
(GUID). When Windows generates a new GUID, it guarantees that the
GUID is unique among all the GUIDs generated throughout the world.
Delphi uses GUIDs to identify and look up
interfaces.
Tips and Tricks
Delphi automatically casts an interface name to its GUID, so you can use the interface name in calls to
QueryInterface
, for example.In an interface declaration, write a GUID in square brackets, e.g.:
type IUnknown = interface ['{00000000-0000-0000-C000-000000000046}']
To generate a new GUID in the IDE, press Ctrl-Shift-G.
GUIDs are optional in interface declarations, but you usually need them. Without a GUID, you cannot cast an interface to another type.
See Also
Interface Keyword, IUnknown Interface, PGUID Type |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.