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;

相关阅读 >>

Delphi abort 用法

Delphi 多种方法查找窗口句柄

Delphi 调用sql和mysql存储过程

Delphi 使电脑睡眠代码

Delphi 判断字符串是否为纯数字组合

Delphi 判断两个时间差是否在一个指定范围内 -withinpastyears、withinpastmonths、withinpastweeks、withinpastdays

Delphi xe string与tstringbuilder的关系

Delphi里label显示多行文本的两种方法

Delphi 获取网卡信息

Delphi 根据盘符弹出u盘

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...