本文整理自网络,侵删。
function GetRandStr(len : Integer; lowercase : Boolean = True; num : Boolean = True; uppercase : Boolean = False) : string;const upperStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; lowerStr = 'abcdefghijklmnopqrstuvwxyz'; numStr = '0123456789';var sourceStr : string; i : Integer;begin sourceStr := ''; Result := ''; if uppercase = True then sourceStr := sourceStr + upperStr; if lowercase = True then sourceStr := sourceStr + lowerStr; if num = True then sourceStr := sourceStr + numStr; if (sourceStr = '') or (len<1) then exit; Randomize; for i:=1 to len do begin Result := Result + sourceStr[Random(Length(sourceStr)-1)+1]; end;end;
相关阅读 >>
Delphi2010读取mysql数据库text类型乱码的解决方案
Delphi 10 seattle的android应用程序中使用参数启动服务
Delphi 窗体的位置和高宽度-tform:letf、top、width、height、clientwidth、clientheight
更多相关阅读请进入《Delphi》频道 >>