Generate a UUID in Delphi

Delphi is a high-level, compiled, strongly typed programming language that supports structured, object-oriented, and generic programming paradigms. It is developed by Embarcadero Technologies (originally by Borland) and is based on the Object Pascal language.

Delphi is designed for rapid application development (RAD) on Windows, macOS, iOS, Android, and Linux platforms. It is widely used for developing a diverse range of applications, from desktop and mobile applications to enterprise-level and database-driven applications.

How to Generate a UUID in Delphi

The Delphi language has built-in support for generating Version 4 UUIDs. Here's an example of how you would create a UUID in Delphi.

uses
System.SysUtils;
var
MyUUID: TGUID;
UUIDString: string;
begin
CreateGUID(MyUUID);
UUIDString := GUIDToString(MyUUID);
ShowMessage(UUIDString);
end;

Explanation

  • On line #2, include the System.SysUtils unit, which contains the CreateGUID function.
  • Line #4 declares a variable of type TGUID, while line #5 declares a string variable.
  • On line #7, the CreateGUID function is called to generate a new UUID and store it in the MyUUID variable.
  • After generating the UUID, you can use the GUIDToString() function to convert the TGUID to a string.

    Note that the string includes braces ({}) around the UUID.


How can we improve this page? Let us know!




The UUIDs generated by this site are provided AS IS without warranty of any kind, not even the warranty that the generated UUIDs are actually unique. You are responsible for using the UUIDs and assume any risk inherent to using them. You are not permitted to use the UUIDs generated by this site if you do not agree to these terms. Do not use any UUIDs found on cached versions of this page.
Privacy Policy
This website uses cookies. We use cookies to personalise content/ads and to analyse our traffic.

The UUIDs generated by this site conform to RFC 4122 whenever possible.
Read more about UUIDs at Wikipedia.
Check out our developer API.

Copyright © 2024 TransparenTech LLC. All Rights Reserved. Contact Us.