Creates a new GUID (globally unique identifier).

CreateGuid([nOutputFormat])

Parameters

nOutputFormat (optional)

default = CREATE_GUID_ANSI

One of the following values.
OutputFormatReturn value
CREATE_GUID_ANSI the Guid is returned as an ansi string
CREATE_GUID_UNICODE the Guid is returned as an unicode string
CREATE_GUID_BINARY the Guid is returned in binary format

Return Value

The GUID, whose format depends on the parameter you send in.

Remarks

While a GUID is generally believed to be globally unique, no guarantee is made that it is Universally Unique. Caution should be used if you intend to deploy your applicaition on other planets.

If you intend to use this function to create a GUID as a primary key for a VFP table using the table's "Default Value", this function must be in scope when adding new records or you will get an error. You may want to use Database Triggers to load VFP2C32 when opening the database to ensure this happens.

Example

Copy code
cId = CreateGuid()
? cId  
* Returns a human-readable 36-character GUID

See Also

Reference

CLSIDFromProgID
CLSIDFromString
CreateThreadObject
GetIUnknown
IsEqualGuid
ProgIDFromCLSID
RegisterActiveObject
RegisterObjectAsFileMoniker
RevokeActiveObject
StringFromCLSID

Used WinApi functions

CoCreateGuid
StringFromGUID2