;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetGUID () intBBSize = 16 hdlBB = BinaryAlloc (intBBSize) BinaryEodSet (hdlBB, intBBSize) DllCall (StrCat (DirWindows (1), "OLE32.DLL"), long:"CoCreateGuid", lpbinary:hdlBB) strGUID = BinaryPeekHex (hdlBB, 0, intBBSize) hdlBB = BinaryFree (hdlBB) Return strGUID ;.......................................................................................................................................... ; Returns a 128-bit GUID as a string of 16 hex values, i. e. 32 ansi chars, e. g. "402380BC5856214AA956C7EE6D4A084A". ; ; Detlev Dalitz.20090416. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfGetGUID2 () intChars = 39 intSizeUnicode = intChars << 1 ; Unicode format requires double sized buffer (2*39 byte) including terminating null characters. intSizeHex = 16 strGUID = "" hdlDLL = DllLoad (StrCat (DirWindows (1), "OLE32.DLL")) hdlBBHex = BinaryAlloc (intSizeHex) hdlBBUnicode = BinaryAlloc (intSizeUnicode) DllCall (hdlDLL, long:"CoCreateGuid", lpbinary:hdlBBHex) If intChars == DllCall (hdlDLL, long:"StringFromGUID2", lpbinary:hdlBBHex, lpbinary:hdlBBUnicode, long:intSizeUnicode) BinaryEodSet (hdlBBUnicode, intSizeUnicode) strGUID = BinaryPeekStrW (hdlBBUnicode, 0, intSizeUnicode) EndIf hdlBBUnicode = BinaryFree (hdlBBUnicode) hdlBBHex = BinaryFree (hdlBBHex) hdlDLL = DllFree (hdlDLL) Return strGUID ;.......................................................................................................................................... ; Returns a 128-bit GUID in a human readable formatted string of hexadecimal numbers grouped by hyphens and enclosed in curly brackets. ; ; Detlev Dalitz.20090416. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ;========================================================================================================================================== :Main strGUID1 = udfGetGUID () ; e. g. "8FE157C842D52E48B3DD04F8AC5AD258" strGUID2 = udfGetGUID2 () ; e. g. "{AC67A70F-3772-48C7-AED2-C95AFB0B38D1}" Exit ;==========================================================================================================================================