Delphi UUID generator

Cruachan picture Cruachan · Feb 20, 2010 · Viewed 32k times · Source

Does Delphi have anything built-in to generate UUIDs?

Answer

Mitch Wheat picture Mitch Wheat · Feb 20, 2010
program Guid;

{$APPTYPE CONSOLE}

uses
SysUtils;

var

Uid: TGuid;
Result: HResult;

begin
Result := CreateGuid(Uid);
if Result = S_OK then
   WriteLn(GuidToString(Uid));
end.

Under the covers CreateGuid() calls one of the various APIs, depending on the platform. For example on Windows, it nowadays calls UuidCreate.