GUID$ function

Purpose

Return a 16-byte (128-bit) Globally Unique Identifier (GUID) or Universally Unique Identifier (UUID) binary string.

Syntax

id$ = GUID$[()]

id$ = GUID$(guidtext$)

Remarks

The GUID$ function, with no parameter (or a null, zero-length string parameter) will return a new, unique 16-byte string GUID (Globally Unique Identifier).  This GUID may be used as a new class identifier or an interface identifier, or for some other purpose where a unique identifier may be required, such as for a one-time encryption key.

If guidtext$ is specified, GUID$ examines a text string, and converts the first standard format, human-readable GUID it finds, and returns a 16-byte binary string.  This 16-byte string contains the internal GUID representation as a 128-bit data item.

To be valid, the GUID string in guidtext$ string must contain exactly 32 hexadecimal digits, optionally delimited by spaces or hyphens, but which must be enclosed overall by curly braces.  For example: "{01234567-89AB-CDEF-FEDC-BA9876543210}".

The GUID$ function is the logical complement to the GUIDTXT$ function.

id$

The return string may be assigned to a dynamic string, or a fixed-length string of at least 16 bytes, or (typically) a GUID variable.  See DIM for more information on creating GUID variables.

Restrictions

If any errors are encountered, GUID$ returns a null (zero-length) string instead of the 16-byte GUID string.  GUID$ can also be used in string equate assignments provided an explicit human-readable GUIDTXT$ argument string is assigned.  For example:

$AppGuid = GUID$("{01234567-89AB-CDEF-FEDC-BA9876543210}")

See also

DIM, CLSID$, GUIDTXT$, INTERFACE/END  INTERFACE, ISNOTHING, ISOBJECT, OBJECT, OBJACTIVE, OBJPTR, OBJRESULT, PROGID$, SET

Example

DIM oID1 AS GUID, oID2 AS GUID

oID1 = GUID$("{01234567-89AB-CDEF-FEDC-BA9876543210}")

oID2 = GUID$("The GUID we need is shown as {0123456789ABCDEFFEDCBA9876543210}")