wiki wrote:A globally unique identifier is a unique reference number used as an identifier in computer software. The term "GUID" typically refers to various implementations of the universally unique identifier (UUID) standard.
GUIDs are usually stored as 128-bit values, and are commonly displayed as 32 hexadecimal digits with groups separated by hyphens.
For example: 21EC2020-3AEA-4069-A2DD-08002B30309D
CreateGUID()
Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
Code: Select all
CreateGUID()
{
VarSetCapacity(pguid, 16, 0)
if !(DllCall("ole32.dll\CoCreateGuid", "ptr", &pguid)) {
size := VarSetCapacity(sguid, (38 << !!A_IsUnicode) + 1, 0)
if (DllCall("ole32.dll\StringFromGUID2", "ptr", &pguid, "ptr", &sguid, "int", size))
return StrGet(&sguid)
}
return ""
}
Code: Select all
MsgBox % CreateGUID() ; ==> {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
- CoCreateGuid function
- StringFromGUID2 function
IsEqualGUID()
Determines whether two GUIDs are equal.
Code: Select all
IsEqualGUID(guid1, guid2)
{
return DllCall("ole32\IsEqualGUID", "ptr", &guid1, "ptr", &guid2)
}
Code: Select all
GUID_1 := CreateGUID()
GUID_2 := CreateGUID()
MsgBox % IsEqualGUID(GUID_1, GUID_2) ; ==> 0
MsgBox % IsEqualGUID(GUID_1, GUID_1) ; ==> 1
- IsEqualGUID function