...create a GUID at runtime?

Author: Thomas Stutz

Category: Strings

uses
  
ComObj, ActiveX;

function CreateGuid: string;
var
  
ID: TGUID;
begin
  
Result := '';
  if CoCreateGuid(ID) = S_OK then
    
Result := GUIDToString(ID);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
Edit1.Text := CreateGuid;
  // or: Edit1.Text := CreateClassID
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base