Gerenating a GUID using Delphi 7

GUID – Globally Unique IDentifier

In Delphi, GUID values are represented with the TGuid record defined in the System unit. A Guid value is a 128-bit integer (16 bytes) that can be used in database applications when a unique identifier is required.
When developing database applications, the TGuidField is used to represents a guid field in a dataset.


procedure TForm1.btnGetGUIDClick(Sender: TObject);
var
  Guid: TGUID;
begin
  CreateGUID(Guid);
  form1.label1.Caption := GUIDToString(Guid);
end;

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.
A Guid value can be converted from a string constant in the following form ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’, in which each x is a hexadecimal digit in the range 0-9 or A-F. For example, ‘123ABC45-65DE-F0F0-4242-A1B2C3D4E5F699’ is a valid uniqueidentifier value.

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.
A Guid value can be converted from a string constant in the following form ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’, in which each x is a hexadecimal digit in the range 0-9 or A-F. For example, ‘123ABC45-65DE-F0F0-4242-A1B2C3D4E5F699’ is a valid uniqueidentifier value.

more info:
http://delphi.about.com/library/weekly/aa022205a.htm

Deixe uma resposta

O seu endereço de email não será publicado. Campos obrigatórios marcados com *