unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function slash(value:string):string; begin if (value='') then result := '' else begin if (value[length(value)]<>'\') then result:=value+'\' else result:=value; end; end; function UniqueFilename(path:string):string; var c : char; begin repeat result := ''; randomize; repeat c:=chr(random(43)+47); if (length(result)=8) then result := result+'.' else if (c in ['0'..'9','A'..'Z']) then result := result+c; until length(result)=12; result := slash(path)+result; until not (fileexists(result)); end; procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text := UniqueFilename('C:\Windows\Desktop'); end; end. |
Subscribe to:
Post Comments (Atom)
0 Response to "Membuat File Unik Pada Delphi 7"
Post a Comment
Silahkan Berkomentar..!!!!