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 安卓读写ini文件

Delphi 批量操作按钮组件属性

Delphi 建立快捷方式的函数: createshortcut

Delphi 网上获取北京时间firedac 下的 sqlite [3] - 获取数据库的基本信息

Delphi打印timage图片

Delphi的窗体文件(dfm)文件中的汉字提取出来?

Delphi获取系统当前进程名和进程id

Delphi 查看dpr文件

Delphi版本号检测判断

Delphi date 返回当前的日期

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



打赏

取消

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

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

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

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

评论

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