Merhaba Arkadaşlar.
Uygulamama otomatik güncelleme tarzı bi küçük uygulama yazıyorum (Discord kullanan var ise bilir.. Uygulama ilk açıldığında updater uygulaması çalışıyor ve son güncellemeleri indirmeden uygulama açılmıyor..)..
Bu uygulamayı da dosya boyutu küçük olsun diye Delphi 7 de yazmaya karar verdim.
Fakat RAR dosyalarını açmayı başaramadım. Bir kaç siteden destek almaya çalıştım ama başaramadım. Acaba unrar işlemini problemsiz yapabilen var mı?
Sıkıştırmak için Delphi üzerinden cmd bat dos komutları ile (RAR_COMPRESS.BAT)
123456 ile dosya şifrelenip dosya adına tarih de verilerek sıkıştırma. (Örnek olarak 123456 şifre verdim)
E:\KAYITLAR klasörünü komple ne varsa sıkıştırıp c:\Yedekleme.rar adında (Tarihli) arşivi oraya (C:\ ye) kaydeder.
C:\Progra~1\WinRAR\WinRAR.exe a -r -M1 -MD4096 -ibck -Y -k -O+ -ac -ep1 -HP123456 -ag+YYYY-MM-DD-HHMI_ "C:\Yedekleme.rar" "E:\KAYITLAR"
Close
Açmak için (UNRAR.BAT)
Password -P123456 Dosya Şifreliyse kullanın, rar şifresi yoksa o kısmı silebilirsin.
c:\Yedekleme.rar üzerindeki arşivi c:\Deneme klasörüne aktarır.
C:\Progra~1\WinRAR\UNRAR.exe X -p123456 C:\Yedekleme.rar C:\DENEME
Close
Winrar.exe ve Unrar.exe Proje dosyanızın olduğu yere de bırakıp dos pathını ona göre ayarlayabilirsiniz.
Böylece component kullanmaya gerek de kalmaz.Sıkıştırırken programın main threadı etkilenmez ayrı bir işlem olarak iş yapar.
Diğer bir öneri 7zip kullanabilirsiniz. Exe ile birlikte işletim sistemine uygun 7z.dll i dağıtmanız yeterli.
Gerekli API ve kullanım için github linki:
https://github.com/geoffsmith82/d7zip/tree/master
Disk üzerindeki dosya üzerinde işlem yapmanın yanında, Tstream desteği ile sıkıştırma ve açma işlerini memory içerisindede yapabilirsiniz.
Password desteği (sıkıştırma ve açma) desteği bulunmakta.
@
frmman hocam.. 7zip denedim. Fakat yanlış işlev hatası verdi.
@
mkysoft hocam bir türlü örneklerden dahi çalıştırmayı başaramadım.
@
COMMANDX hocam Parametre ile yapamadım.
ShellExecute(Handle, 'open', PChar('"C:\Progra~1\WinRAR\UNRAR.exe X "'+ updfolder + '\aaa.rar '+ updfolder), nil, nil, 0);
Burada hata bile vermiyor.. ama unrar da yapmıyor..
@
frmman ve @
mkysoft hocam herhangi bi projenizde kullandınız mı bu componentleri? örnek kullanımı var mı? PAss veya progressbar a da hiç ihtiyacım yok ama bir türlü çalıştıramadım
Delphinin yenü sürümlerinde dosya boyutu ne kadar küçültülebiliyor? (Sıkıştırmadan)
Yeni sürümde dahili zip ile lzma (7z temeli) desteği dahi var.
(15-03-2024, Saat: 16:32)mcuyan Adlı Kullanıcıdan Alıntı: [ -> ]@frmman hocam.. 7zip denedim. Fakat yanlış işlev hatası verdi.
@mkysoft hocam bir türlü örneklerden dahi çalıştırmayı başaramadım.
@COMMANDX hocam Parametre ile yapamadım.
ShellExecute(Handle, 'open', PChar('"C:\Progra~1\WinRAR\UNRAR.exe X "'+ updfolder + '\aaa.rar '+ updfolder), nil, nil, 0);
Burada hata bile vermiyor.. ama unrar da yapmıyor..
@frmman ve @mkysoft hocam herhangi bi projenizde kullandınız mı bu componentleri? örnek kullanımı var mı? PAss veya progressbar a da hiç ihtiyacım yok ama bir türlü çalıştıramadım
Evet kullandım. Password lü sıkıştırma ve açma işlemlerini uygulama içerisinden yapmıştım. İlk fırsatta örnek uygulama paylaşmaya çalışacağım.
Project1.dpr Dosyası
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FolderDialog, ComCtrls,shellapi;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
FolderDialog1: TFolderDialog;
ComboBox1: TComboBox;
Label1: TLabel;
Button1: TButton;
ComboBox2: TComboBox;
Button2: TButton;
ComboBox3: TComboBox;
CheckBox1: TCheckBox;
Edit1: TEdit;
Label2: TLabel;
ComboBox4: TComboBox;
Label3: TLabel;
Label4: TLabel;
Button3: TButton;
Edit2: TEdit;
Label5: TLabel;
Memo1: TMemo;
TabSheet3: TTabSheet;
Button4: TButton;
ComboBox5: TComboBox;
Button5: TButton;
OpenDialog1: TOpenDialog;
ComboBox6: TComboBox;
Edit3: TEdit;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetTempDir: string;
var
lng: DWORD;
begin
SetLength(Result, MAX_PATH);
lng := GetTempPath(MAX_PATH, PChar(Result));
SetLength(Result, lng);
end;
function ShortPathName(const LongPathName: string): string;
var
Retval: DWORD;
Buff: array [0..MAX_PATH-1] of Char;
begin
Retval := GetShortPathName(PChar(LongPathName), Buff, Length(Buff));
Win32Check(Retval <> 0);
Result := Buff;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if FolderDialog1.Execute then begin
ComboBox1.Text:=FolderDialog1.Directory+'\winrar.exe';
ComboBox2.Text:=FolderDialog1.Directory+'\unrar.exe';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if folderDialog1.Execute then begin
combobox3.Text:=FolderDialog1.Directory;
end;
button2.Enabled:=false;
button3.Enabled:=true;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if FolderDialog1.Execute then begin
combobox4.Text:=FolderDialog1.Directory+'\'+edit2.Text;
end;
button2.Enabled:=true;
button3.Enabled:=false;
//------rar işlemi cmd -------------
memo1.Clear;
if checkbox1.Checked=true then begin
memo1.Lines.Add(combobox1.Text+' a -r -M1 -MD4096 -ibck -Y -k -O+ -ac -ep1 -HP'+edit1.text+' -ag+YYYY-MM-DD-HHMI_ "'+combobox4.Text+'" "'+shortPathName(combobox3.Text)+'"');
memo1.Lines.Add('Close');
end;
if checkbox1.Checked=false then begin
memo1.Lines.Add(combobox1.Text+' a -r -M1 -MD4096 -ibck -Y -k -O+ -ac -ep1 -HP'+edit1.text+' "'+combobox4.Text+'" "'+ShortPathname(combobox3.Text)+'"');
memo1.Lines.Add('Close');
end;
MEMO1.Lines.SaveToFile(GetTempDir+'RAR_CMD_001.BAT');
ShellExecute(Handle, 'open', PChar(GetTempDir+'RAR_CMD_001.BAT'), nil, nil, SW_SHOW);
// PChar(GetTempDir+'RAR_CMD_001.BAT'), nil, nil, SW_HIDE); // İsteğe göre işlem gizli
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if OpenDialog1.Execute then begin
combobox5.Text:=OpenDialog1.FileName;
end;
Button4.Enabled:=false;
Button5.Enabled:=true;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if FolderDialog1.Execute then begin
combobox6.Text:=FolderDialog1.Directory;
end;
memo1.Clear;
memo1.Lines.Add(combobox2.Text+' x '+' -p'+edit3.Text+' '+combobox5.Text+' '+combobox6.Text);
memo1.Lines.Add('close');
MEMO1.Lines.SaveToFile(GetTempDir+'UNRAR_CMD_001.BAT');
ShellExecute(Handle, 'open', PChar(GetTempDir+'UNRAR_CMD_001.BAT'), nil, nil, SW_SHOW);
// PChar(GetTempDir+'UNRAR_CMD_001.BAT'), nil, nil, SW_HIDE); // İsteğe göre işlem gizli
end;
end.
unit1.dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 558
Height = 252
Caption = 'Form1'
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 PageControl1: TPageControl
Left = 0
Top = 0
Width = 550
Height = 168
ActivePage = TabSheet3
Align = alClient
TabOrder = 0
object TabSheet1: TTabSheet
Caption = 'S'#305'k'#305#351't'#305'r-RAR'
object Label2: TLabel
Left = 104
Top = 12
Width = 41
Height = 13
Caption = 'Rar '#350'ifre'
end
object Label3: TLabel
Left = 2
Top = 37
Width = 93
Height = 13
Caption = 'Ar'#351'ivlenecek Klas'#246'r'
end
object Label4: TLabel
Left = 6
Top = 75
Width = 47
Height = 13
Caption = 'Ar'#351'iv Yolu'
end
object Label5: TLabel
Left = 241
Top = 10
Width = 74
Height = 13
Caption = 'Ar'#351'iv Dosya Ad'#305
end
object Button2: TButton
Left = 344
Top = 30
Width = 121
Height = 25
Caption = 'Ar'#351'ivlenecek Klas'#246'r-Se'#231
TabOrder = 0
OnClick = Button2Click
end
object ComboBox3: TComboBox
Left = 96
Top = 32
Width = 249
Height = 21
ItemHeight = 13
TabOrder = 1
end
object CheckBox1: TCheckBox
Left = 3
Top = 11
Width = 97
Height = 17
Caption = 'Tarihle S'#305'k'#305#351't'#305'r'
TabOrder = 2
end
object Edit1: TEdit
Left = 153
Top = 8
Width = 81
Height = 21
TabOrder = 3
Text = '123456'
end
object ComboBox4: TComboBox
Left = 96
Top = 72
Width = 249
Height = 21
ItemHeight = 13
TabOrder = 4
end
object Button3: TButton
Left = 344
Top = 69
Width = 121
Height = 25
Caption = 'Ar'#351'ivle (Nereye)'
Enabled = False
TabOrder = 5
OnClick = Button3Click
end
object Edit2: TEdit
Left = 320
Top = 4
Width = 145
Height = 21
TabOrder = 6
Text = 'deneme.rar'
end
end
object TabSheet3: TTabSheet
Caption = #199#246'z-UNRAR'
ImageIndex = 2
object Label6: TLabel
Left = 48
Top = 13
Width = 132
Height = 13
Caption = 'Varsa Rar Dosyas'#305'n'#305'n '#350'ifresi'
end
object Button4: TButton
Left = 408
Top = 42
Width = 131
Height = 25
Caption = 'Rar Nerede'
TabOrder = 0
OnClick = Button4Click
end
object ComboBox5: TComboBox
Left = 6
Top = 43
Width = 401
Height = 21
ItemHeight = 13
TabOrder = 1
Text = 'RAR dosyan'#305'z'#305' Se'#231'in'
end
object Button5: TButton
Left = 408
Top = 74
Width = 129
Height = 25
Caption = 'Rar Nerede A'#231#305'ls'#305'n'
TabOrder = 2
OnClick = Button5Click
end
object ComboBox6: TComboBox
Left = 4
Top = 77
Width = 403
Height = 21
ItemHeight = 13
TabOrder = 3
end
object Edit3: TEdit
Left = 192
Top = 8
Width = 121
Height = 21
TabOrder = 4
Text = '123456'
end
end
object TabSheet2: TTabSheet
Caption = 'Ayarlar'
ImageIndex = 1
object Label1: TLabel
Left = 0
Top = 8
Width = 31
Height = 13
Caption = 'Winrar'
end
object ComboBox1: TComboBox
Left = 48
Top = 4
Width = 361
Height = 21
ItemHeight = 13
TabOrder = 0
Text = 'C:\Progra~1\WinRAR\Winrar.exe'
Items.Strings = (
'C:\Program Files\WinRAR\winrar.exe'
'C:\Program Files (x86)\WinRAR\winrar.exe')
end
object Button1: TButton
Left = 416
Top = 0
Width = 113
Height = 25
Caption = 'Winrar Klas'#246'r'#252' Nerede'
TabOrder = 1
OnClick = Button1Click
end
object ComboBox2: TComboBox
Left = 48
Top = 32
Width = 361
Height = 21
ItemHeight = 13
TabOrder = 2
Text = 'C:\Progra~1\WinRAR\Unrar.exe'
Items.Strings = (
'C:\Program Files\WinRAR\unrar.exe'
'C:\Program Files (x86)\WinRAR\unrar.exe')
end
end
end
object Memo1: TMemo
Left = 0
Top = 168
Width = 550
Height = 57
Align = alBottom
ScrollBars = ssVertical
TabOrder = 1
end
object FolderDialog1: TFolderDialog
Caption = 'Winrar Klas'#246'r'#252' Nerede'
DialogX = 0
DialogY = 0
Version = '1.1.0.0'
Left = 8
Top = 184
end
object OpenDialog1: TOpenDialog
Left = 264
Top = 112
end
end
Teşekkürler @
COMMANDX farklı bir açıdan çözüm önerisi sundunuz ama arşivi açan password ün bat dosyası içinde açıkda bulunması, şifre ile koruma yapma mantığına ters düşmüyor mu ?
