Delphi

uses   SysUtils;

// 生成GUID
function TForm2.GetGUID: string;
var
  LTep: TGUID;
  sGUID: string;
begin
  CreateGUID(LTep);
  sGUID := GuidToString(LTep);
  sGUID := StringReplace(sGUID, '-', '', [rfReplaceAll]);
  sGUID := Copy(sGUID, 2, length(sGUID) - 2);
  Result := sGUID;
end;

参考:

https://www.cnblogs.com/xwgcxk/p/7233683.html  

原文地址:https://www.cnblogs.com/sunylat/p/14397731.html