U盘备份工具
這段時間作畢設,老是拿著U盤到處跑,很累。
有時候,就是一不小心,自己在電腦上做好了,到了導師那里總是出現莫名其妙的錯誤,奇怪!這個地方我明明修改好了,為了到了這里還出錯?奇了!
導師為此很生氣,“你上次來的時候就是這里出錯,想不到過了一個星期竟然還沒改正!這幾天你干什么了!”
我冤死,我。。。。
其實,我最新做出來的東西沒拷出來,還在我電腦上放著呢。我日!
想了想,怎么辦?自己做一個得了,貌似我在網上還沒聽過這類工具呢。搜U盤就是一大堆的U盤病毒或者專殺工具之類的,都說現在網絡很方便,怎么隨便一個小工具都得自己親自動手啊,沒天理了。。。
這幾天忙畢設忙得要死,還得準備隨時會來的清考。。。
沒時間了,上網查了一點資料,最核心的部分找到了,先放出來,等日后空閑了再補上這一塊,或者兄弟你有時間就幫我一把,現在把最核心的部分放出來。
這里是單元部分的代碼,采用的是Delphi語言,其實C++也是一樣的,反正都是調用Windows API。
?
Code?1unit?Main;
?2
?3interface
?4
?5uses
?6??Windows,?Messages,?SysUtils,?Variants,?Classes,?Graphics,?Controls,?Forms,
?7??Dialogs,?Buttons,?StdCtrls,?ExtCtrls;
?8
?9type
10??TForm1?=?class(TForm)
11????OpenDialog1:?TOpenDialog;
12????Edit1:?TEdit;
13????Label1:?TLabel;
14????SpeedButton1:?TSpeedButton;
15????SpeedButton2:?TSpeedButton;
16????txtAge:?TLabeledEdit;
17????procedure?SpeedButton1Click(Sender:?TObject);
18????procedure?SpeedButton2Click(Sender:?TObject);
19??private
20????{?Private?declarations?}
21??public
22????{?Public?declarations?}
23??end;
24
25var
26??Form1:?TForm1;
27
28implementation
29
30{$R?*.dfm}
31
32procedure?TForm1.SpeedButton1Click(Sender:?TObject);
33begin
34??if?self.OpenDialog1.Execute?then
35????Edit1.Text?:=?self.OpenDialog1.FileName;
36end;
37
38procedure?TForm1.SpeedButton2Click(Sender:?TObject);
39var
40??t:?Integer;//獲得文件對標準開始(貌似是1970年)的秒數
41begin
42??t?:=?FileAge(Edit1.Text);
43??//格式化成為標準時間格式
44??txtAge.Text?:=?DateTimeToStr(FileDateToDateTime(t));
45end;
?
這里是窗體部分的代碼:
?
Codeobject?Form1:?TForm1
??Left?=?244
??Top?=?189
??BorderStyle?=?bsDialog
??Caption?=?'Form1'
??ClientHeight?=?123
??ClientWidth?=?573
??Color?=?clBtnFace
??Font.Charset?=?DEFAULT_CHARSET
??Font.Color?=?clWindowText
??Font.Height?=?-11
??Font.Name?=?'MS?Sans?Serif'
??Font.Style?=?[]
??OldCreateOrder?=?False
??PixelsPerInch?=?96
??TextHeight?=?13
??object?Label1:?TLabel
????Left?=?24
????Top?=?24
????Width?=?84
????Height?=?13
????Caption?=?#25991#20214#20840#36335#24452#21517#65306
??end
??object?SpeedButton1:?TSpeedButton
????Left?=?462
????Top?=?19
????Width?=?89
????Height?=?25
????Caption?=?#25171#24320#25991#20214
????OnClick?=?SpeedButton1Click
??end
??object?SpeedButton2:?TSpeedButton
????Left?=?462
????Top?=?72
????Width?=?89
????Height?=?25
????Caption?=?#33719#24471#20462#25913#26102#38388
????OnClick?=?SpeedButton2Click
??end
??object?Edit1:?TEdit
????Left?=?120
????Top?=?20
????Width?=?321
????Height?=?21
????TabOrder?=?0
??end
??object?txtAge:?TLabeledEdit
????Left?=?120
????Top?=?72
????Width?=?321
????Height?=?21
????EditLabel.Width?=?93
????EditLabel.Height?=?13
????EditLabel.Caption?=?#25991#20214#20462#25913#26102#38388#65306'???'
????LabelPosition?=?lpLeft
????TabOrder?=?1
??end
??object?OpenDialog1:?TOpenDialog
????Filter?=?'XML'#25991#20214'|*.xml|'#25152#26377#25991#20214'|*.*'
????Left?=?258
????Top?=?42
??end
end
?
把上面的兩個分別保存成pas和dfm文件,然后調用就可以看到效果了。下面是我做出來的效果:
我的想法就是通過計算文件的修改事件來獲得是從U盤拷出來還是從電腦拷到U盤上去,至于其他的,不難了吧。。
?
已經找到同步工具,暫時不考慮這個問題了!
轉載于:https://www.cnblogs.com/lenic/archive/2009/03/15/1412178.html
總結
- 上一篇: IPGUARD Linux系统客户端安装
- 下一篇: SuMa++论文阅读