function RandomStr(majuscule:boolean;lowercase:boolean;number:boolean;digit:integer):string; //大写字母,小写字母,数字,字符串的位数 var i: Byte; s: string; begin if majuscule then s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' else s := '';
if lowercase then s := s + 'abcdefghijklmnopqrstuvwxyz';
if number then s := s + '0123456789'; if s = '' then exit;
Result := ''; for i := 0 to digit-1 do //根据长度来循环 begin Randomize;//每次都初始化随机种子 Result := Result + s[Random(Length(s)-1)+1]; end; end;