end.
unit BackUpUnit; //数据备份
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, shellapi;
type TBackUpForm = class(TForm) Panel1: TPanel; Edit_path: TEdit; Label3: TLabel; Label4: TLabel; Select: TButton; Panel_button: TPanel; Bevel_button: TBevel; OKBtn: TButton; CancelBtn: TButton; procedure OKBtnClick(Sender: TObject); procedure Edit_pathChange(Sender: TObject); procedure FormCreate(Sender: TObject); procedure SelectClick(Sender: TObject); procedure CancelBtnClick(Sender: TObject); procedure Edit_pathEnter(Sender: TObject); private { Private declarations } public B_showmessage: boolean; { Public declarations } end;
var BackUpForm: TBackUpForm;
implementation uses FunctionUnit, SelectDirUnit; {$R *.dfm}
procedure TBackUpForm.OKBtnClick(Sender: TObject); var SFilePath, DFilePath, SourcePath: string; MesString: string; OpStruc: TSHFileOpStruct; FromBuf, ToBuf: array[0..255] of Char; ShouldCopy: Boolean; sr: TSearchRec; FileAttrs: Integer; label COPYAGAIN; begin COPYAGAIN: // 准备目录拷贝 FillChar(FromBuf, Sizeof(FromBuf), 0); FillChar(ToBuf, Sizeof(ToBuf), 0); // 设置OpStruc with OpStruc do begin Wnd := Handle; wFunc := FO_COPY; pFrom := @FromBuf; pTo := @ToBuf; fFlags := FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION; fAnyOperationsAborted := False; hNameMappings := nil; lpszProgressTitle := nil; end;
SourcePath := ExtractFileDir(Application.ExeName); if (StrLen(PChar(SourcePath)) <> 3) then SourcePath := SourcePath + '\'; FillChar(FromBuf, Sizeof(FromBuf), 0); FillChar(ToBuf, Sizeof(ToBuf), 0); SFilePath := SourcePath + 'data'; StrPCopy(FromBuf, Pchar(SFilePath)); DFilePath := Edit_path.Text; StrPCopy(ToBuf, Pchar(DFilePath)); // 检测源路径是否存在 if (not DirectoryExists(SFilePath)) then begin if B_showmessage then begin MesString := '源数据库目录' + SFilePath + '已被破坏,系统不能进行备份。'; MessageBox(Handle, PChar(MesString), '错误', MB_OK + MB_ICONERROR); end; exit; end; if uppercase(SFilePath) = uppercase(DFilePath) then begin if B_showmessage then &n
首页 上一页 9 10 11 12 13 14 15 下一页 尾页 12/16/16