- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 生成可以控制最大32位随机英文数字字符串
Uses ActiveX;
//随机英文数字 dInt 长度 1-32
function Rand(dInt: Integer):string;
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, dInt);
end
else
ShowMessage('Create GUID error!');
// ShowMessage(sGUID);
end;
Result:=sGUID;
end;
//调用方法
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(Rand(32));
end;