?? backup_form.pas
字號:
unit BackUp_Form;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TFlatGaugeUnit, StdCtrls, TFlatEditUnit, ExtCtrls,FileCtrl;
type
TBackup_F = class(TForm)
Label1: TLabel;
Label2: TLabel;
ZT_FE: TFlatEdit;
JD_FG: TFlatGauge;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Backup_F: TBackup_F;
implementation
{$R *.dfm}
Uses
ExtIniFiles,StrUtils;
function GetFileNum(dir:string):integer;
var
sr:Tsearchrec;
begin
result:=0;
if findfirst(dir,faanyfile,sr)=0 then
repeat
if(sr.Attr<>fadirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
result:=result+1;
until findnext(sr)<>0;
end;
//***********************************************************************************
procedure Wait(second:Longint);
var
FirstTickCount:longint;
begin
FirstTickCount:=GetTickCount;
repeat
Application.ProcessMessages;
until ((GetTickCount-FirstTickCount) >=second);
end;
//***********************************************************************************
procedure TBackup_F.Timer1Timer(Sender: TObject);
var
myini:TExtIniFile;
cz,num:integer;
spath,dpath,name,RQ:string;
sr:Tsearchrec;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
Timer1.Enabled:=false;
myini:=TExtIniFile.Create(ExtractFilePath(Application.ExeName)+'set.ini');
cz:=myini.ReadInteger('bakup','CZ',0);
if cz=0 then
begin
spath:=ExtractFilePath(Application.ExeName)+'Data';
dpath:=myini.ReadString('bakup','BakPath','');
dpath:=dpath+'\'+AnsiReplaceStr(DateTimeToStr(now),':','');
ForceDirectories(dpath);
num:=GetFileNum(spath+'\*.*');
ZT_FE.Text:='正在備份數(shù)據(jù)庫......';
JD_FG.MaxValue:=num;
if findfirst(spath+'\*.*',faanyfile,sr)=0 then
repeat
if(sr.Attr<>fadirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
begin
copyfile(pchar(spath+'\'+sr.Name),pchar(dpath+'\'+sr.Name),false);
JD_FG.Progress:=JD_FG.Progress+1;
end;
Wait(100);
until findnext(sr)<>0;
ZT_FE.Text:='數(shù)據(jù)庫備份成功';
MessageBox(handle,'恭喜你:數(shù)據(jù)庫備份成功!','祝賀你',MB_OK or MB_ICONINFORMATION);
end
else begin
RQ:=myini.ReadString('bakup','RQ','');
spath:=myini.ReadString('bakupdian',RQ,'');
spath:=spath+'\'+RQ;
dpath:=ExtractFilePath(Application.ExeName);
dpath:=dpath+'Data';
num:=GetFileNum(spath+'\*.*');
ZT_FE.Text:='正在還原數(shù)據(jù)庫......';
JD_FG.MaxValue:=num;
if findfirst(spath+'\*.*',faanyfile,sr)=0 then
repeat
if(sr.Attr<>fadirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
begin
copyfile(pchar(spath+'\'+sr.Name),pchar(dpath+'\'+sr.Name),false);
JD_FG.Progress:=JD_FG.Progress+1;
end;
Wait(100);
until findnext(sr)<>0;
ZT_FE.Text:='數(shù)據(jù)庫還原成功';
MessageBox(handle,'恭喜你:數(shù)據(jù)庫還原成功!','祝賀你',MB_OK or MB_ICONINFORMATION);
end;
StartupInfo.cb:=sizeof(StartupInfo);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
CreateProcess(pchar(ExtractFilePath(Application.ExeName)+'TSGL.exe'),nil,nil,nil,false,0,nil,nil,StartupInfo,ProcessInfo);
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -