Author Topic: GUID Conversion Functions  (Read 1426 times)

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
GUID Conversion Functions
« on: August 25, 2020, 11:08:10 PM »
[UPDATED  8/28/2020]
Updated the included demonstration and added the following routine to the library.

SUB NEW_GUID ( _GUID AS LPGUID)  ' Fills a GUID structure with a new GUID
  CoCreateGuid( _GUID )
END SUB

*********************************************************************************************************

I've been wanting to revisit this topic for a little while.  I'm certainly no expert on this subject but I think the following information and code should be mostly stable and useful at times.

Attached are three functions ( and a demonstration ) that could be all you'll ever need when converting between human-readable GUID / UUID and its complementary binary structure form.  Rounding out the library is an earlier uploaded function NewGUID$ which creates a new, unique, human-readable GUID string that you can use, save, share or convert to its binary form.

If you find bugs or ways to improve this library, please share them here.  Thanks -MrBcx-
« Last Edit: August 28, 2020, 02:36:56 PM by MrBcx »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2538
    • View Profile
Re: GUID Conversion Functions
« Reply #1 on: July 29, 2024, 02:25:42 PM »
[UPDATED  7/29/2024]

I updated the demonstration and its associated library. 

[See attachment]

The library now consists of four functions (no more SUBS)

FUNCTION BinaryGuid AS GUID     
' Returns a unique (random-generated) GUID in its BINARY format

FUNCTION NewGUID AS STRING
' Returns a unique (randomly-generated) GUID string, in human-readable format

FUNCTION String2GUID (MyStr$) AS GUID 
' Returns the BINARY version of its string GUID argument

FUNCTION Guid2String AS STRING (Arg AS GUID)   
' Returns a GUID in human-readable format from its binary GUID argument