To create a GUID (Globally Unique Identifier) at runtime I have two different ways of doing this.
First Method
Add ComObj unit to the uses clause, if not already there, then to create the GUID as a string just do the following:
FThisID := CreateClassID;
Second Method
This method you need the SysUtils in the uses clause. The do something like the following:
var
newGUID: TGUID;
begin
SysUtils.CreateGUID(newGUID);
FThisID := GUIDToString(newGUID);
end;
Or just TGUID.NewGuid.ToString
ReplyDeleteYes Stefan, that is simpler, thanks I will use that in future.
ReplyDeleteNewer delphi version have record helpers which allow TGuid.Creat
ReplyDelete