unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, sButton, sEdit;
type
TForm1 = class(TForm)
sEdit1: TsEdit;
sButton1: TsButton;
procedure sButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetGUID: string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
function TForm1.GetGUID: string;
var
LTep: TGUID;
sGUID: string;
begin
CreateGUID(LTep); //更新GUID
sGUID := GUIDToString(LTep);
sGUID := StringReplace(sGUID, '-', '', [rfReplaceAll]); //去掉-线
sGUID := Copy(sGUID, 2, Length(sGUID) - 2); //去掉大括号
Result := sGUID;
end;
procedure TForm1.sButton1Click(Sender: TObject);
begin
sEdit1.Text:= GetGUID;
end;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, sButton, sEdit;
type
TForm1 = class(TForm)
sEdit1: TsEdit;
sButton1: TsButton;
procedure sButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetGUID: string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
function TForm1.GetGUID: string;
var
LTep: TGUID;
sGUID: string;
begin
CreateGUID(LTep); //更新GUID
sGUID := GUIDToString(LTep);
sGUID := StringReplace(sGUID, '-', '', [rfReplaceAll]); //去掉-线
sGUID := Copy(sGUID, 2, Length(sGUID) - 2); //去掉大括号
Result := sGUID;
end;
procedure TForm1.sButton1Click(Sender: TObject);
begin
sEdit1.Text:= GetGUID;
end;
end.