Собственно весь код, но я его использовал со старого проекта.
Я вызываю SaveDialog1 Кнопкой, в принципе я больше за вариант
unit MainUnit;
interface
uses
Winapi.Windows, System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms,
Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Samples.Spin, RegExpr, System.SyncObjs,
Winapi.ShellAPI, Vcl.Dialogs, Winapi.Messages, Graphics,
System.Generics.Collections, Vcl.Samples.Gauges, System.StrUtils,
scControls, Vcl.ComCtrls, System.NetEncoding;
type
TFormMain = class(TForm)
Panel2: TPanel;
ButtonPathBase: TButton;
ButtonPathProxy: TButton;
CheckBoxDuplicates: TCheckBox;
Panel3: TPanel;
TimerProxy: TTimer;
TimerLog: TTimer;
Panel6: TPanel;
LabelBase: TLabel;
OpenDialog1: TOpenDialog;
Button1: TButton;
Button2: TButton;
SaveDialog1: TSaveDialog;
procedure ButtonPathBaseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ButtonResultClick(Sender: TObject);
procedure ButtonPathBaseMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure ButtonPathProxyMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure ButtonPathProxyClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
public
{ Public declarations }
private
BaseDrag, ProxyDrag: Boolean;
Regex: TRegExpr;
OldNameLog: string;
protected
function StartCheckBaseProxy: Boolean;
procedure OpenBase(fname: string);
procedure ClearDataCheck;
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
procedure MergeStrings(Dest, Source: TStrings) ;
end;
type
TBrutThread = class(TThread)
private
fLogin: string;
fPassw: string;
protected
procedure WriteOneString(fname: string);
public
end;
var
FormMain: TFormMain;
ProxyList, BaseList: TStringList;
BaseCount, ProxiesCount: Integer;
CheckCount, CheckProxyCount: Integer;
CriticalSection: TCriticalSection;
NameLog: string;
LI: TlistItem;
BrutThreadList: TObjectList<TBrutThread>;
implementation
{$R *.dfm}
procedure TFormMain.MergeStrings(Dest, Source: TStrings) ;
var j : integer;
begin
for j := 0 to -1 + Source.Count do
if Dest.IndexOf(Source[j]) = -1 then
Dest.Add(Source[j]) ;
end;
function TFormMain.StartCheckBaseProxy: Boolean;
begin
Result := false;
if BaseList.Count > 0 then
begin
end
else
MessageBox(Handle, 'Not loaded accounts!', 'Error', MB_OK);
if Result then
begin
CreateDir(NameLog);
OldNameLog := NameLog;
end;
end;
procedure TFormMain.ClearDataCheck;
begin
CheckCount := 0;
CheckProxyCount := 0;
end;
procedure TBrutThread.WriteOneString(fname: string);
var
WrFileS: TextFile;
begin
AssignFile(WrFileS, fname);
if FileExists(fname) then
Append(WrFileS)
else
Rewrite(WrFileS);
writeln(WrFileS, fLogin + ':' + fPassw);
CloseFile(WrFileS);
end;
procedure TFormMain.OpenBase(fname: string);
begin
if BrutThreadList.Count = 0 then
begin
if CheckBoxDuplicates.Checked then
begin
BaseList.Sorted := True;
BaseList.Duplicates := dupIgnore;
end
else
begin
BaseList.Sorted := false;
BaseList.Duplicates := dupAccept;
end;
BaseList.LoadFromFile(fname);
LabelBase.Caption := 'Base: ' + IntToStr(BaseList.Count);
BaseCount := BaseList.Count;
end;
end;
procedure TFormMain.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
if FileExists(SaveDialog1.FileName) then
raise Exception.Create('File already exists. Cannot overwrite.')
else
OpenBase(SaveDialog1.FileName);
end;
procedure TFormMain.ButtonPathBaseClick(Sender: TObject);
begin
if OpenDialog1.Execute then
OpenBase(OpenDialog1.FileName);
end;
procedure TFormMain.ButtonPathBaseMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
BaseDrag := True;
ProxyDrag := false;
end;
procedure TFormMain.ButtonPathProxyClick(Sender: TObject);
begin
if OpenDialog1.Execute then
OpenBase(OpenDialog1.FileName);
end;
procedure TFormMain.ButtonPathProxyMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
ProxyDrag := True;
BaseDrag := false;
end;
procedure TFormMain.ButtonResultClick(Sender: TObject);
begin
ShellExecute(Handle, 'open', PWideChar(OldNameLog), nil, nil, SW_SHOWNORMAL);
end;
procedure TFormMain.WMDropFiles(var Msg: TWMDropFiles);
const
maxlen = 254;
var
h: THandle;
pchr: array[0..maxlen] of char;
fname: string;
begin
FormMain.Cursor := crDefault;
h := Msg.Drop;
DragQueryFile(h, 0, pchr, maxlen);
fname := string(pchr);
if lowercase(extractfileext(fname)) = '.txt' then
begin
if BaseDrag then
OpenBase(fname)
;
end;
DragFinish(h);
end;
procedure TFormMain.FormCreate(Sender: TObject);
begin
OpenDialog1.Filter := 'Text files (*.txt)|*.TXT|Any file (*.*)|*.*';
SaveDialog1.Filter := 'Text files (*.txt)|*.TXT|Any file (*.*)|*.*';
NameLog := ExtractFileDir(Application.ExeName) + '\' +
FormatDateTime('dd.mm.yyyy"-"hh.nn.ss', Now) + '_ComboEditor';
DragAcceptFiles(Handle, True);
Regex := TRegExpr.Create;
BrutThreadList := TObjectList<TBrutThread>.Create(false);
CriticalSection := TCriticalSection.Create;
ProxyList := TStringList.Create;
BaseList := TStringList.Create;
end;
end.