DELPHI生成32位随机字符串(数字和大写字母混合)
来源:互联网 发布:gts450 mac 最新驱动 编辑:程序博客网 时间:2024/04/30 07:57
unit Unit1;interfaceuses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxLookAndFeels, ActiveX, cxLookAndFeelPainters, Vcl.Menus, dxSkinsCore, dxSkinOffice2013White, Vcl.StdCtrls, cxButtons;type TForm1 = class(TForm) cxbtn1: TcxButton; procedure cxbtn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.cxbtn1Click(Sender: TObject);var I: Integer; sGUID : string; TmpGUID: TGUID;begin for I := 0 to 10 do begin if CoCreateGUID(TmpGUID) = S_OK then begin sGUID := GUIDToString(TmpGUID); sGUID := Copy(StringReplace(sGUID, '-', '', [rfReplaceAll, rfIgnoreCase]), 2, 32); end else ShowMessage('Create GUID error!'); ShowMessage(sGUID); end;end;end.