随机字符串函数
可以使用大写 小写 数字 以及混合
function RandomStr(Upper: boolean; Lower: boolean; Number: boolean;
StrLength: Integer): string;
var
i: Byte;
s: string;
begin
if Upper then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';
if Lower then
s := s + 'abcdefghijklmnopqrstuvwxyz';
if Number then
s := s + '0123456789';
if s = '' then
exit;
result := '';
for i := 0 to StrLength - 1 do // 根据长度来循环
begin
Randomize; // 每次都初始化随机种子
result := result + s[Random(Length(s) - 1) + 1];
end;
end;