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 winexec 执行cmd

Delphi 学习 sql 语句 - insert、update、delete

Delphi extctrls.frame3d

Delphi 操作webbrowser 元素值

Delphi firedac 获取mysql 数据库databases 列表

Delphi 18位身份证号码的校验

Delphi中move 函数额用法

Delphi 让程序自己更新本程序

Delphi splitter 控件属性及作用

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



打赏

取消

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

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

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

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

评论

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