X
xiang330381
Unregistered / Unconfirmed
GUEST, unregistred user!
我在做数据备份和还原的时候,老出现这些变量未声明,如什么tshfileopstruct,fanyoperationsaborted等,可是这些不是delphi系统有的吗?想请那位大虾该看一下!谢谢,代码如下:
unit bfhyut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ComCtrls, ExtCtrls,shellapi;
type
Tsjbffm = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ProgressBar1: TProgressBar;
Timer1: TTimer;
Label1: TLabel;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
sjbffm: Tsjbffm;
implementation
{$R *.dfm}
procedure Tsjbffm.SpeedButton1Click(Sender: TObject);
var
opstruc:tshfileopstruct;
frombuf,tobuf:array[0..128]of char;
begin
timer1.Enabled:=true;
progressbar1.Position:=0;
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,pchar('data/11.mdb'));
strpcopy(tobuf,pchar('backup/'));
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;
if shfileoperation(opstruc)=0 then
begin
end;
end;
procedure Tsjbffm.SpeedButton2Click(Sender: TObject);
var
opstruc:tshfileopstruct;
frombuf,tobuf:array[0..128]of char;
begin
timer1.Enabled:=true;
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,pchar('backup/kcgl.mdb'));
strpcopy(tobuf,pchar('data/'));
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;
if shfileoperation(opstruc)=0 then
begin
end;
end;
procedure Tsjbffm.Timer1Timer(Sender: TObject);
begin
progressbar1.Position:=progressbar1.Position+10;
if progressbar1.Position=40 then
begin
timer1.Enabled:=false;
showmessage('操作成功!');
progressbar1.Position:=0;
end;
end;
end.
unit bfhyut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ComCtrls, ExtCtrls,shellapi;
type
Tsjbffm = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ProgressBar1: TProgressBar;
Timer1: TTimer;
Label1: TLabel;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
sjbffm: Tsjbffm;
implementation
{$R *.dfm}
procedure Tsjbffm.SpeedButton1Click(Sender: TObject);
var
opstruc:tshfileopstruct;
frombuf,tobuf:array[0..128]of char;
begin
timer1.Enabled:=true;
progressbar1.Position:=0;
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,pchar('data/11.mdb'));
strpcopy(tobuf,pchar('backup/'));
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;
if shfileoperation(opstruc)=0 then
begin
end;
end;
procedure Tsjbffm.SpeedButton2Click(Sender: TObject);
var
opstruc:tshfileopstruct;
frombuf,tobuf:array[0..128]of char;
begin
timer1.Enabled:=true;
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,pchar('backup/kcgl.mdb'));
strpcopy(tobuf,pchar('data/'));
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;
if shfileoperation(opstruc)=0 then
begin
end;
end;
procedure Tsjbffm.Timer1Timer(Sender: TObject);
begin
progressbar1.Position:=progressbar1.Position+10;
if progressbar1.Position=40 then
begin
timer1.Enabled:=false;
showmessage('操作成功!');
progressbar1.Position:=0;
end;
end;
end.