Unit1.pas
上传用户:rick3344
上传日期:2013-02-03
资源大小:225k
文件大小:2k
源码类别:

源码/资料

开发平台:

WINDOWS

  1. unit Unit1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls;
  6. type
  7.   TForm1 = class(TForm)
  8.     Button1: TButton;
  9.     Edit1: TEdit;
  10.     Edit2: TEdit;
  11.     Edit3: TEdit;
  12.     Edit4: TEdit;
  13.     Edit5: TEdit;
  14.     Button2: TButton;
  15.     Label1: TLabel;
  16.     Label2: TLabel;
  17.     ComboBox1: TComboBox;
  18.     Label3: TLabel;
  19.     Memo1: TMemo;
  20.     procedure Button1Click(Sender: TObject);
  21.     procedure Button2Click(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.     function GetString(Number:Integer;MaskStr:String):String;
  27.     function AnserStr(ty:Integer):String;
  28.   end;
  29.   TGetString=Function (Number:Integer):String;
  30.   //function getstring(Num:Integer):String;External 'wfh.dll';
  31. var
  32.   Form1: TForm1;
  33. implementation
  34. {$R *.dfm}
  35. function TForm1.AnserStr(ty:Integer):String;
  36. begin
  37. end;
  38. procedure TForm1.Button1Click(Sender: TObject);
  39. var
  40.   sn:string;
  41.   hInstance:Cardinal;
  42.   GetString:TGetString;
  43. begin
  44.     hInstance:=LoadLibrary('wfh.dll');
  45.     if hInstance<>0 then
  46.     begin
  47.        GetString:=GetProcAddress(hInstance,'GetString');
  48.        Edit5.Text:=GetString(12);
  49.     end;
  50.     freeLibrary(hInstance);
  51. end;
  52. Function TForm1.GetString(Number:Integer;MaskStr:String):string;
  53. var
  54.       SetChar:Array[0..61] of char;
  55.       Temp:Array of char;
  56.       i:Integer;
  57.       tmp:String;
  58. begin
  59.    for i:=0 to 9 do
  60.      SetChar[i]:=chr(i+48);
  61.    for i:=10 to 35 do
  62.      SetChar[i]:=chr(i+55);
  63.    for i:=36 to 61 do
  64.      SetChar[i]:=chr(i+61);
  65.    Randomize();
  66.    SetLength(Temp,number-1);
  67.    for i:=0 to number-1 do
  68.    begin
  69.        tmp:='';
  70.        if length(trim(MaskStr))>=i then
  71.           tmp:=Copy(trim(MaskStr),i+1,1)
  72.        else
  73.           tmp:='';
  74.        if tmp='A' then
  75.           Temp[i]:=SetChar[Random(10000) mod 26 + 10]
  76.        else if tmp='a' then
  77.           Temp[i]:=SetChar[Random(10000) mod 26 + 36]
  78.        else if tmp='#' then
  79.           Temp[i]:=SetChar[Random(10000) mod 52 + 10]
  80.        else if tmp='9' then
  81.           Temp[i]:=SetChar[Random(10000) mod 10]
  82.        else
  83.           Temp[i]:=SetChar[Random(10000) mod 61];
  84.        tmp:='';
  85.    end;
  86.    result:=pchar(Temp);
  87. end;
  88. procedure TForm1.Button2Click(Sender: TObject);
  89. begin
  90.     Edit5.Text:=GetString(20,ComboBox1.Text);
  91.     Edit1.Text:=Copy(Edit5.Text,0,4);
  92.     Edit2.Text:=Copy(Edit5.Text,5,4);
  93.     Edit3.Text:=Copy(Edit5.Text,9,4);
  94.     Edit4.Text:=Copy(Edit5.Text,13,4);
  95. end;
  96. end.