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开发桌面图标列表查看程序

Delphi idsmtp发送邮件的问题

Delphi多线程学习:多线程数据库查询(ado)

isleapyear:返回给定的年份是否是闰年

Delphi android应用程序的关闭退出

Delphi读写firebird二进制数据

Delphi tms web core webmemo 横竖滚动条

Delphi 如何在定义局部变量时赋初始值

Delphi开发ie右键菜单扩展

Delphi application.processmessages的作用

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



打赏

取消

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

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

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

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

评论

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