(Delphi DLL) Generate UUID
Generates a version 4 UUID, using either uppercase or lowercase hex.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, StringBuilder;
...
procedure TForm1.Button1Click(Sender: TObject);
var
sb: HCkStringBuilder;
lowercase: Boolean;
begin
sb := CkStringBuilder_Create();
// Generate a lowercase UUID.
lowercase := True;
CkStringBuilder_AppendUuid(sb,lowercase);
Memo1.Lines.Add(CkStringBuilder__getAsString(sb));
// example: edb1bb24-e9be-4ada-98bd-c2d893f29f55
lowercase := False;
CkStringBuilder_Clear(sb);
CkStringBuilder_AppendUuid(sb,lowercase);
Memo1.Lines.Add(CkStringBuilder__getAsString(sb));
// example: 338EAF28-631E-4303-BE27-A8D80E9191CB
CkStringBuilder_Dispose(sb);
end;
|