1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229:
| unit main;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Shellapi, Inifiles, StdCtrls, IDGlobal, FileCtrl, ComCtrls, Menus, StrUtils;
Const WM_TASKBAREVENT = WM_USER + 1;
type TForm1 = class(TForm) Timer1: TTimer; ListBox1: TListBox; Edit1: TEdit; Label1: TLabel; ComboBox1: TComboBox; Label2: TLabel; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Edit2: TEdit; Button5: TButton; Label3: TLabel; Edit3: TEdit; Label4: TLabel; PopupMenu1: TPopupMenu; LetztesBackup1: TMenuItem; NchstesBackup1: TMenuItem; JetztSichern1: TMenuItem; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure PopupMenu1Popup(Sender: TObject); procedure JetztSichern1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure ListBox1Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure WMTaskbarEvent(var Message: TMessage); message WM_TASKBAREVENT; private procedure copy_all_that_shit; procedure AppMinimize(Sender: TObject); public end;
var Form1: TForm1; Datum : String; Ini: TIniFile;
implementation
{$R *.dfm}
procedure TaskBarAddIcon; var tnid: TNotifyIconData; Owner: HWnd; begin with tnid do begin cbSize := SizeOf(TNotifyIconData); Wnd := Form1.Handle; uID := 1; uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; uCallbackMessage := WM_TASKBAREVENT; hIcon := Application.Icon.Handle; end; StrCopy(tnid.szTip, 'sup4u BackupSystem'); Shell_NotifyIcon(NIM_ADD, @tnid); Owner:=GetWindow(Form1.Handle,GW_OWNER); If Owner<>0 Then ShowWindow(Owner,SW_HIDE); end;
procedure TaskBarRemoveIcon; var tnid: TNotifyIconData; Owner: HWnd; begin tnid.cbSize := SizeOf(TNotifyIconData); tnid.Wnd := Form1.Handle; tnid.uID := 1; Shell_NotifyIcon(NIM_DELETE, @tnid); Owner:=GetWindow(Form1.Handle,GW_OWNER); If Owner<>0 Then Begin ShowWindow(Owner,SW_Show); ShowWindow(Owner,SW_Normal); End; end;
procedure TForm1.WMTaskbarEvent(var Message: TMessage); var Point: TPoint; begin case Message.LParamLo of WM_LBUTTONDOWN: TaskBarRemoveIcon; WM_RBUTTONDOWN: begin SetForegroundWindow(Handle); GetCursorPos(point); popupmenu1.popup(point.x,point.y); end; end; end;
procedure TForm1.copy_all_that_shit; var i: integer; mitte, ordner : string; Begin if (edit2.Text<>'') and (listbox1.Count>0) then begin for i:=0 to listbox1.Count-1 do begin ordner:=ReverseString(LeftStr(ReverseString(listbox1.items[i]),pos('\',ReverseString(listbox1.items[i]))-1)); if not DirectoryExists(edit2.text + '\' + ordner) then mkdir(edit2.text + '\' + ordner); mitte:=listbox1.items[i] + ' ' + edit2.text + '\' + ordner + ' /E /C /H /R /D'; Shellexecute(Form1.Handle,nil,'xcopy', pchar(mitte), '', SW_HIDE); end; if combobox1.Text='Wochen' then Datum:=datetimetostr(now + (strtoint(edit1.text) * 7)); if combobox1.Text='Tage' then Datum:=datetimetostr(now + strtoint(edit1.text)); Ini.WriteString('MAIN','Datum',Datum); Ini.WriteString('MAIN','Last',datetimetostr(now)); end else showmessage('Nicht erfolgreich. Entweder kein Zielordner oder keine Dateien'); end;
procedure TForm1.Timer1Timer(Sender: TObject); begin if copy(datetimetostr(now),0,13) = copy(Datum,0,13) then copy_all_that_shit; end;
procedure TForm1.FormCreate(Sender: TObject); begin Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + '\Einstellung.ini'); try Datum := Ini.ReadString( 'MAIN', 'Datum', ''); if strtodatetime(Datum) < now then Showmessage('Ihre Daten wurden schon zu lange nicht mehr gesichert'); edit1.Text := Ini.ReadString( 'MAIN', 'Value', ''); if Ini.ReadString( 'MAIN', 'Kind', '') = 'Tage' then combobox1.ItemIndex:=0; if Ini.ReadString( 'MAIN', 'Kind', '') = 'Wochen' then combobox1.ItemIndex:=1; ini.ReadSection('Dirs', ListBox1.Items); edit2.text:=Ini.ReadString('MAIN','Ziel',''); edit3.text:=Ini.ReadString('MAIN','Uhr',''); button5.Enabled:=false; Application.OnMinimize := AppMinimize; TaskBarAddIcon; except end; end;
procedure TForm1.Button1Click(Sender: TObject); var chosenDirectory :string; begin SelectDirectory('Select a directory', '', chosenDirectory); if (chosenDirectory<>'') then listbox1.Items.Add(chosenDirectory); end;
procedure TForm1.Button3Click(Sender: TObject); var i: integer; begin if (IsNumeric(edit1.Text)) and (IsNumeric(edit3.Text)) and (combobox1.ItemIndex<>-1) then begin if combobox1.Text='Wochen' then Datum:=datetimetostr(now + (strtoint(edit1.text) * 7)); if combobox1.Text='Tage' then Datum:=datetimetostr(now + strtoint(edit1.text)); Ini.WriteString('MAIN','Datum',Datum); Ini.WriteString('MAIN','Kind',Combobox1.Text); Ini.WriteString('MAIN','Value',edit1.text); Ini.WriteString('MAIN','Uhr',edit3.text); ini.EraseSection('Dirs'); for i:=0 to listbox1.count -1 do begin ini.WriteString('Dirs',listbox1.Items[i],'mmh'); end; Ini.WriteString('MAIN','Ziel',edit2.text); end; end;
procedure TForm1.Button4Click(Sender: TObject); var chosenDirectory :string; begin SelectDirectory('Select a directory', '', chosenDirectory); if (chosenDirectory<>'') then edit2.Text:=chosenDirectory; end;
procedure TForm1.ListBox1Click(Sender: TObject); begin if (listbox1.ItemIndex<>-1) then button5.Enabled:=true else button5.Enabled:=false; end;
procedure TForm1.Button5Click(Sender: TObject); begin listbox1.DeleteSelected; end;
procedure TForm1.Button2Click(Sender: TObject); begin copy_all_that_shit; end;
procedure TForm1.AppMinimize(Sender: TObject); begin hide; TaskBarAddIcon; end;
procedure TForm1.JetztSichern1Click(Sender: TObject); begin copy_all_that_shit; end;
procedure TForm1.PopupMenu1Popup(Sender: TObject); begin LetztesBackup1.Caption:='Letztes Backup: ' + Ini.ReadString('MAIN','Last','') + ' Uhr'; NchstesBackup1.Caption:='Nächstes Backup: ' + Datum + ' Uhr'; end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin TaskBarRemoveIcon; end;
end. |