Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi UUID generator

Tags:

uuid

delphi

Does Delphi have anything built-in to generate UUIDs?

like image 555
Cruachan Avatar asked Feb 20 '10 01:02

Cruachan


People also ask

How do I generate a GUID in Delphi?

To create a sample GUID, hit CTRL + SHIFT + G in the code editor, this will create a unique GUID value, like this one: ['{B54ED86E-211F-4803-AF46-0586DA66C583}']. Each time you press CTRL + SHIFT + G, you'll get a new Guid value.

How do I make a global unique identifier?

Users do not need to rely on a centralized authority to administer GUIDs, as anyone can use a generation algorithm to create a GUID. Individuals and organizations can create GUIDs using a free GUID generator that is available online. An online generator constructs a unique GUID according to RFC 4122.


2 Answers

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.

like image 181
Mitch Wheat Avatar answered Oct 09 '22 07:10

Mitch Wheat


Also, if you need a GUID for an interface declaration, hit ctrl+shift+g in the code editor to insert a GUID at the caret.

like image 37
Nat Avatar answered Oct 09 '22 09:10

Nat