function getguid: string;
var
SGUID: TGUID;
sstr:string;
begin
CreateGUID(sguid);
sstr:=guidtostring(sguid);
sstr:=StringReplace(sstr,'{','',[rfReplaceAll]);
sstr:=StringReplace(sstr,'}','',[rfReplaceAll]);
if length(sstr)>1 then result:=sstr //加个判断
else result:='errorGUID';
end;
使用
showmessage(getguid);
结果 8CFC62B8-6CF4-4301-A6C0-22DA16C22CEE