-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.pas.bak
2647 lines (2494 loc) · 122 KB
/
main.pas.bak
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, Grids,
StdCtrls, About, PoiskVBaze, help,
PodborZameni, sqlite3conn, sqldb, db, LCLType, winpeimagereader, elfreader, machoreader,
LCLIntF, Clipbrd, DBGrids, DbCtrls, ExtCtrls, ComCtrls, LazHelpHTML, LazUTF8,
lconvencoding, Registry, ComObj, Windows, StrUtils, ActiveX,
IdHTTP, lazutf8classes, HelpIntfs, LResources, LCLProc, Types, FileCtrl,
LazFileUtils, LazUtils, RichMemo, Messages, ShellApi;
type
{ TfMian }
TfMian = class(TForm)
bDeinstrall: TButton;
bExplorer: TButton;
bRegedit: TButton;
bRuchPoisk: TButton;
bSearch: TButton;
bUkazKatalog: TButton;
bOpenKatPodrob: TButton;
bViewZamPodrob: TButton;
cbZamenaPodrob: TComboBox;
ComboBox1: TComboBox;
DataSource1: TDataSource;
DataSourceAllVar: TDataSource;
DataSource3: TDataSource;
DataSource4: TDataSource;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
DBGridAllVar: TDBGrid;
FD: TFontDialog;
IdHTTP1: TIdHTTP;
ImageList1: TImageList;
leStoimostPodrob: TLabeledEdit;
leLicensePodrob: TLabeledEdit;
leTypePoPodrob: TLabeledEdit;
leInstallDatePodrob: TLabeledEdit;
leRazrabPodrob: TLabeledEdit;
leVersionPodrob: TLabeledEdit;
leKatalogPodrob: TLabeledEdit;
leKluchPodrob: TLabeledEdit;
leIshName: TLabeledEdit;
leNamePodrob: TLabeledEdit;
lProgress: TLabel;
leDisplayName: TLabeledEdit;
leFullPathKey: TLabeledEdit;
leInstallDate: TLabeledEdit;
leKatalog: TLabeledEdit;
leKatalogSearch: TLabeledEdit;
leKeyName: TLabeledEdit;
leRazrab: TLabeledEdit;
leVersionProg: TLabeledEdit;
ListBox1: TListBox;
MainMenu1: TMainMenu;
mBeginSerch: TMenuItem;
mAbout: TMenuItem;
mCopy: TMenuItem;
Memo1: TMemo;
mHelp: TMenuItem;
mSupport: TMenuItem;
PageControl1: TPageControl;
PageControl2: TPageControl;
Panel1: TPanel;
PanelInstalled: TPanel;
pPeredatExcel: TMenuItem;
pExportHTML: TMenuItem;
pExportCSV: TMenuItem;
pExport: TMenuItem;
mUpdateCheck: TMenuItem;
mPodborZameni: TMenuItem;
mPoiskVBaze: TMenuItem;
mExportHTML: TMenuItem;
mPeredatExcel: TMenuItem;
pOchistka: TMenuItem;
mExport: TMenuItem;
mOchistit: TMenuItem;
pCopy: TMenuItem;
mWebStranica: TMenuItem;
ProgressBar1: TProgressBar;
pSortByZamena: TMenuItem;
pSortByName: TMenuItem;
pSortByType: TMenuItem;
pSortByLic: TMenuItem;
pSortByStoimost: TMenuItem;
pShrift: TMenuItem;
pBeginSearch: TMenuItem;
pVidMenu: TMenuItem;
pSearchMenu: TMenuItem;
mSort04: TMenuItem;
mSort03: TMenuItem;
mSort01: TMenuItem;
mSort02: TMenuItem;
mSort00: TMenuItem;
mShrift: TMenuItem;
mVid: TMenuItem;
mSpravka: TMenuItem;
mSearch: TMenuItem;
mExit: TMenuItem;
mFile: TMenuItem;
PopupMenu1: TPopupMenu;
RichMemo1: TRichMemo;
rVetkaReestra: TRadioGroup;
SD3: TSaveDialog;
SD2: TSaveDialog;
SD: TSaveDialog;
SelectDirectoryDialog1: TSelectDirectoryDialog;
SQLite3Connection1: TSQLite3Connection;
SQLQuery1: TSQLQuery;
SQLQuery2: TSQLQuery;
SQLQuery3: TSQLQuery;
SQLQuery4: TSQLQuery;
SQLQueryAllVar: TSQLQuery;
SQLTransaction1: TSQLTransaction;
AvtoPoiskPage: TTabSheet;
RuchPoiskPage: TTabSheet;
SQLTransaction3: TSQLTransaction;
InstallPoPage: TTabSheet;
SQLTransaction4: TSQLTransaction;
tsLicenseSogl: TTabSheet;
tsVseVarianti: TTabSheet;
tsPodrobnosti: TTabSheet;
ToolBar1: TToolBar;
panExit: TToolButton;
panExportCSV: TToolButton;
panExportHTML: TToolButton;
panPeredatExcel: TToolButton;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
panBeginSerch: TToolButton;
panOchistit: TToolButton;
panPoiskVBaze: TToolButton;
panPodborZameni: TToolButton;
ToolButton3: TToolButton;
panSort00: TToolButton;
panSort01: TToolButton;
panSort02: TToolButton;
panSort03: TToolButton;
panSort04: TToolButton;
ToolButton4: TToolButton;
panAbout: TToolButton;
panUpdateCheck: TToolButton;
panHelp: TToolButton;
procedure AvtoPoiskPageContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
procedure bDeinstrallClick(Sender: TObject);
procedure bExplorerClick(Sender: TObject);
procedure bOpenKatPodrobClick(Sender: TObject);
procedure bRegeditClick(Sender: TObject);
procedure bRuchPoiskClick(Sender: TObject);
procedure bUkazKatalogClick(Sender: TObject);
procedure bViewZamPodrobClick(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure ListBox1SelectionChange(Sender: TObject; User: boolean);
procedure mAboutClick(Sender: TObject);
procedure mBeginSerchClick(Sender: TObject);
procedure mExitClick(Sender: TObject);
procedure mExportClick(Sender: TObject);
procedure mExportHTMLClick(Sender: TObject);
procedure mHelpClick(Sender: TObject);
procedure mOchistitClick(Sender: TObject);
procedure mPeredatExcelClick(Sender: TObject);
procedure mPodborZameniClick(Sender: TObject);
procedure mPoiskVBazeClick(Sender: TObject);
procedure mShriftClick(Sender: TObject);
procedure mSort00Click(Sender: TObject);
procedure mSort01Click(Sender: TObject);
procedure mSort02Click(Sender: TObject);
procedure mSort03Click(Sender: TObject);
procedure mSort04Click(Sender: TObject);
procedure mSupportClick(Sender: TObject);
procedure mUpdateCheckClick(Sender: TObject);
procedure mWebStranicaClick(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure pCopyClick(Sender: TObject);
procedure rVetkaReestraSelectionChanged(Sender: TObject);
procedure JumpToKey(Key: string);
private
{ private declarations }
public
MyFiltrList: TStringListUTF8; //хранит список названий установленных программ
path : TSelectDirectoryDialog; // для ручного поиска
put:string; // для ручного поиска
MyRegistry2: TRegistry;
UninstallKey: String;
MyList3: TStringListUTF8; // для хранения названий ключей реестра Installed
nilAvtoSearch : Byte;
putLicSog:string;
{ public declarations }
end;
var
fMian: TfMian;
MyList: TStringList;
implementation
{$R *.lfm}
{ TfMian }
procedure TfMian.mExitClick(Sender: TObject);
begin
Close;
end;
procedure TfMian.mExportClick(Sender: TObject);
//экспорт в csv
const
Delim = CHR(9);
var
S: String;
I: Integer;
Stream: TFileStream;
filename : String;
begin
// если открыт авто поиск
if PageControl1.ActivePageindex=0 then
begin
SD.FileName:=filename;
if SD.Execute then
begin
filename:=SD.FileName;
Stream := TFileStream.Create(filename, fmCreate);
S := '';
for I := 0 to DBGrid1.Columns.Count - 1 do
if DBGrid1.Columns[I].Visible=true then S := S + TColumn(DBGrid1.Columns[I]).Title.Caption + Delim;
S := UTF8ToCP1251(S + CHR(13));
Stream.Write(PChar(S)^, Length(S));
while not DBGrid1.DataSource.DataSet.Eof do
begin
S := '';
for I := 0 to DBGrid1.Columns.Count - 1 do
if DBGrid1.Columns[I].Visible=true then S := S + TColumn(DBGrid1.Columns[I]).Field.AsString + Delim;
S := UTF8ToCP1251(S + CHR(13));
Stream.Write(PChar(S)^, Length(S));
DBGrid1.DataSource.DataSet.Next();
end;
Stream.Free();
// if FileExists(filename) then OpenDocument(filename); //открытие документа после сохранения
end;
end;
// если открыт ручной поиск
if PageControl1.ActivePageindex=1 then
begin
SD.FileName:=filename;
if SD.Execute then
begin
filename:=SD.FileName;
Stream := TFileStream.Create(filename, fmCreate);
S := '';
for I := 0 to DBGrid2.Columns.Count - 1 do
if DBGrid2.Columns[I].Visible=true then S := S + TColumn(DBGrid2.Columns[I]).Title.Caption + Delim;
S := UTF8ToCP1251(S + CHR(13));
Stream.Write(PChar(S)^, Length(S));
while not DBGrid2.DataSource.DataSet.Eof do
begin
S := '';
for I := 0 to DBGrid2.Columns.Count - 1 do
if DBGrid2.Columns[I].Visible=true then S := S + TColumn(DBGrid2.Columns[I]).Field.AsString + Delim;
S := UTF8ToCP1251(S + CHR(13));
Stream.Write(PChar(S)^, Length(S));
DBGrid2.DataSource.DataSet.Next();
end;
Stream.Free();
// if FileExists(filename) then OpenDocument(filename); //открытие документа после сохранения
end;
end;
end;
Function Repa(s:string):string; // для экспорта в штмл
var
nl:Word; // было Integer
cStr:string;
begin
CStr:=s;
for nl:= 1 to length(cStr) do if cStr[nl] = '.' then cStr[nl]:= ',';
Repa:=CStr;
end;
procedure TfMian.mExportHTMLClick(Sender: TObject);
var
t:TStringList;
i:Integer;
s:string;
filename : String;
begin
// если открыт авто поиск
if PageControl1.ActivePageindex=0 then
begin
SD2.FileName:=filename;
if SD2.Execute then
begin
filename:=SD2.FileName;
t:=TStringList.Create;
DBGrid1.DataSource.DataSet.first;
t.add('<html>');
t.add('<head>');
t.add('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
t.add('</head>');
t.add('<h1 align=center>Lpro - Проверка лицензий установленных программ</h1>');
t.add('<html>');
t.add('<table border=1 align=center>');
//
t.add('<tr>');
t.add('<td> Исходное название');
t.add('<td> Название в БД');
t.add('<td> Тип ПО');
t.add('<td> Лицензия');
t.add('<td> Стоимость');
t.add('<td> Замена');
t.add('</tr>');
//
t.add('<tr>');
for i:=6 to DBGrid1.DataSource.DataSet.Fields.Count-1 do
t.add('<td>'+DBGrid1.DataSource.DataSet.fields[i].fieldname);
t.add('</tr>');
while not DBGrid1.DataSource.DataSet.eof do
begin
s:='<tr>';
for i:=0 to DBGrid1.DataSource.DataSet.Fields.Count-1 do
s:=s+'<td>'+DBGrid1.DataSource.DataSet.fields[i].AsString;
s:=s+'</tr>';
t.add(SysToUTF8(s)); // UTF8ToCP1251
DBGrid1.DataSource.DataSet.next;
end;
t.add('</table>');
t.add('<p align=center>Официальный сайт: <a href="http://xn--90abhbolvbbfgb9aje4m.xn--p1ai/">КонтинентСвободы.рф</a></p>');
t.add('</html>');
t.savetofile(filename);
end;
DBGrid1.DataSource.DataSet.first;
end;
// если открыт ручной поиск
if PageControl1.ActivePageindex=1 then
begin
SD2.FileName:=filename;
if SD2.Execute then
begin
filename:=SD2.FileName;
t:=TStringList.Create;
DBGrid2.DataSource.DataSet.first;
t.add('<html>');
t.add('<head>');
t.add('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
t.add('</head>');
t.add('<h1 align=center>Lpro - Проверка лицензий установленных программ</h1>');
t.add('<html>');
t.add('<table border=1 align=center>');
//
t.add('<tr>');
t.add('<td> ID');
t.add('<td> Название');
t.add('<td> Тип ПО');
t.add('<td> Лицензия');
t.add('<td> Стоимость');
t.add('<td> Замена');
t.add('</tr>');
//
t.add('<tr>');
for i:=6 to DBGrid2.DataSource.DataSet.Fields.Count-1 do
t.add('<td>'+DBGrid2.DataSource.DataSet.fields[i].fieldname);
t.add('</tr>');
while not DBGrid2.DataSource.DataSet.eof do
begin
s:='<tr>';
for i:=0 to DBGrid2.DataSource.DataSet.Fields.Count-1 do
s:=s+'<td>'+DBGrid2.DataSource.DataSet.fields[i].AsString;
s:=s+'</tr>';
t.add(SysToUTF8(s)); // UTF8ToCP1251
DBGrid2.DataSource.DataSet.next;
end;
t.add('</table>');
t.add('<p align=center>Официальный сайт: <a href="http://xn--90abhbolvbbfgb9aje4m.xn--p1ai/">КонтинентСвободы.рф</a></p>');
t.add('</html>');
t.savetofile(filename);
end;
DBGrid2.DataSource.DataSet.first;
end;
end;
procedure TfMian.mHelpClick(Sender: TObject);
begin
//WinExec('hh.exe Lpro.chm',SW_SHOW);
fHelp.Show;
end;
procedure TfMian.mOchistitClick(Sender: TObject);
begin
bOpenKatPodrob.Enabled:=False;
cbZamenaPodrob.Enabled:=False;
bViewZamPodrob.Enabled:=False;
lProgress.Caption:='';
ProgressBar1.Position:=0;
DBGrid1.DataSource.DataSet.DisableControls; //очистка dbgrid кнопка очистка
try
DBGrid1.DataSource.DataSet.First;
while not DBGrid1.DataSource.DataSet.Eof
do DBGrid1.DataSource.DataSet.Delete;
finally
DBGrid1.DataSource.DataSet.EnableControls;
end;
bSearch.Visible:=True;
nilAvtoSearch:=0;
end;
procedure TfMian.mPeredatExcelClick(Sender: TObject);
var
i,j,index: Integer;
ExcelApp,sheet: Variant;
ClassID: TCLSID;
Rez : HRESULT;
//экспорт в эксель
begin
// если открыт авто поиск
if PageControl1.ActivePageindex=0 then
begin
Rez := CLSIDFromProgID(PWideChar(WideString('Excel.Application')), ClassID);
if Rez <> S_OK then begin
MessageDlg('EXCEL не установлен. Поддерживается передача только в EXCEL.',mtERROR,[mbok],0);
Exit;
end;
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Visible := False;
ExcelApp.WorkBooks.Add(-4167);
ExcelApp.WorkBooks[1].WorkSheets[1].name := 'Export';
sheet:=ExcelApp.WorkBooks[1].WorkSheets['Export'];
index:=1; //Загоняем с первой строки
DBGrid1.DataSource.DataSet.First;
for i:=1 to DBGrid1.DataSource.DataSet.RecordCount do
begin
for j:=1 to DBGrid1.DataSource.DataSet.FieldCount do
sheet.cells[index,j]:=DBGrid1.DataSource.DataSet.fields[j-1].AsWideString;
inc(index);
DBGrid1.DataSource.DataSet.Next;
end;
ExcelApp.Visible := true;
end;
// если открыт ручной поиск
if PageControl1.ActivePageindex=1 then
begin
Rez := CLSIDFromProgID(PWideChar(WideString('Excel.Application')), ClassID);
if Rez <> S_OK then begin
MessageDlg('EXCEL не установлен. Поддерживается передача только в EXCEL.',mtERROR,[mbok],0);
Exit;
end;
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Visible := False;
ExcelApp.WorkBooks.Add(-4167);
ExcelApp.WorkBooks[1].WorkSheets[1].name := 'Export';
sheet:=ExcelApp.WorkBooks[1].WorkSheets['Export'];
index:=1; //Загоняем с первой строки
DBGrid2.DataSource.DataSet.First;
for i:=1 to DBGrid2.DataSource.DataSet.RecordCount do
begin
for j:=1 to DBGrid2.DataSource.DataSet.FieldCount do
sheet.cells[index,j]:=DBGrid2.DataSource.DataSet.fields[j-1].AsWideString;
inc(index);
DBGrid2.DataSource.DataSet.Next;
end;
ExcelApp.Visible := true;
end;
end;
procedure TfMian.mPodborZameniClick(Sender: TObject);
begin
fPodborZameni.ShowModal;
end;
procedure TfMian.mPoiskVBazeClick(Sender: TObject);
begin
fPoiskVBaze.ShowModal;
end;
procedure TfMian.mShriftClick(Sender: TObject);
begin
//сначала диалогу присваиваем шрифт:
FD.Font:= DBGrid1.Font;
//если диалог прошел успешно, меняем шрифт:
if FD.Execute then DBGrid1.Font:= FD.Font;
end;
procedure TfMian.mWebStranicaClick(Sender: TObject);
begin
OpenURL('http://xn--90abhbolvbbfgb9aje4m.xn--p1ai/%D1%83%D1%82%D0%B8%D0%BB%D0%B8%D1%82%D1%8B/%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0/lpro-%D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0-%D0%BB%D0%B8%D1%86%D0%B5%D0%BD%D0%B7%D0%B8%D0%B9-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC.html');
end;
procedure TfMian.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePageindex=1 then
begin
mBeginSerch.Enabled := False;
mOchistit.Enabled := False;
panBeginSerch.Enabled := False;
panOchistit.Enabled := False;
panSort00.Enabled := False;
panSort01.Enabled := False;
panSort02.Enabled := False;
panSort03.Enabled := False;
panSort04.Enabled := False;
mSort00.Enabled := False;
mSort01.Enabled := False;
mSort02.Enabled := False;
mSort03.Enabled := False;
mSort04.Enabled := False;
mExport.Enabled := True;
mExportHTML.Enabled := True;
mPeredatExcel.Enabled := True;
panExportCSV.Enabled := True;
panExportHTML.Enabled := True;
panPeredatExcel.Enabled := True;
end;
if PageControl1.ActivePageindex=2 then
begin
mBeginSerch.Enabled := False;
mOchistit.Enabled := False;
panBeginSerch.Enabled := False;
panOchistit.Enabled := False;
panSort00.Enabled := False;
panSort01.Enabled := False;
panSort02.Enabled := False;
panSort03.Enabled := False;
panSort04.Enabled := False;
mSort00.Enabled := False;
mSort01.Enabled := False;
mSort02.Enabled := False;
mSort03.Enabled := False;
mSort04.Enabled := False;
mExport.Enabled := False;
mExportHTML.Enabled := False;
mPeredatExcel.Enabled := False;
panExportCSV.Enabled := False;
panExportHTML.Enabled := False;
panPeredatExcel.Enabled := False;
end;
if PageControl1.ActivePageindex=0 then
begin
mBeginSerch.Enabled := True;
mOchistit.Enabled := True;
panBeginSerch.Enabled := True;
panOchistit.Enabled := True;
panSort00.Enabled := True;
panSort01.Enabled := True;
panSort02.Enabled := True;
panSort03.Enabled := True;
panSort04.Enabled := True;
mSort00.Enabled := True;
mSort01.Enabled := True;
mSort02.Enabled := True;
mSort03.Enabled := True;
mSort04.Enabled := True;
mExport.Enabled := True;
mExportHTML.Enabled := True;
mPeredatExcel.Enabled := True;
panExportCSV.Enabled := True;
panExportHTML.Enabled := True;
panPeredatExcel.Enabled := True;
end;
end;
procedure TfMian.pCopyClick(Sender: TObject);
//var
// bm: TBookMark;
// pch, pch1: PChar;
// s, s2: string;
// i, j: integer; // Копирование выделения
Const
//Tab character // НАВЕРНОЕ СТОИТ УБРАТЬ, не требуется
Delim = CHR(9);
var // отключил пункт в меню !!!!!!!!!!!
i: Integer;
x: Integer;
S: String;
Y: String;
begin
//Copy Fieldnames First
Y := '';
for x := 0 to DBGrid1.Columns.Count - 1 do
Y := Y + (format('%s',[DBGrid1.columns[x].title.caption]))+ Delim;
Memo1.Lines.Add(Y);
//Copy Field contents
if DBGrid1.SelectedRows.Count > 0 then
begin
with DBGrid1.DataSource.DataSet do
begin
for i := 0 to DBGrid1.SelectedRows.Count-1 do
begin
//Bookmark sets the position of the selection
S := '';
GotoBookmark(Tbookmark(DBGrid1.SelectedRows[i]));
for x := 0 to DBGrid1.Columns.Count - 1 do
Begin
S := S + (format('%s',[DbGrid1.columns[x].field.asString]))+ Delim;
end;
Memo1.Lines.Add(S);
end;
end;
end;
//Copy to a memo field, then to the clipboard
Memo1.SelectAll;
Memo1.CopyToClipboard;
{*
s := '';
for j := 0 to DBGrid1.Columns.Count - 1 do
s := s + DBGrid1.Columns.Items[j].Title.Caption + #9;
s := s + #13 + #10;
if not DBGrid1.DataSource.DataSet.active then
begin
ShowMessage('Нет выборки!!!');
Exit;
end;
try
DBGrid1.Visible := False; //Делаем грид невидимым, чтобы не тратилось время
//на его перерисовку при прокрутке DataSet - просто и
//эффективно
bm := DBGrid1.DataSource.DataSet.GetBookmark; // для того чтобы не
// потерять текущую запись
DBGrid1.DataSource.DataSet.First;
while not DBGrid1.DataSource.DataSet.EOF do
begin
s2 := '';
for j := 0 to DBGrid1.Columns.Count - 1 do
begin
s2 := s2 + DBGrid1.Columns.Items[j].Field.AsString + #9;
end;
s := s + s2 + #13 + #10;
DBGrid1.DataSource.DataSet.Next;
end;
//Переключаем клавиатуру "в русский режим",
//иначе - проблемы с кодировкой
GetMem(pch, 100);
GetMem(pch1, 100);
GetKeyboardLayoutName(pch);
StrCopy(pch1, pch);
while pch <> '00000419' do
begin
ActivateKeyboardLayout(HKL_NEXT, 0);
GetKeyboardLayoutName(pch);
if strComp(pch, pch1) = 0 then
//Круг замкнулся - нет такого языка '00000419'
StrCopy(pch, '00000419');
end;
clipboard.AsText := s; //Данные - в буфер!!!
//Возвращаем режим клавиатуры
while strComp(pch, pch1) <> 0 do
begin
ActivateKeyboardLayout(HKL_NEXT, 0);
GetKeyboardLayoutName(pch);
end;
FreeMem(pch);
FreeMem(pch1);
DBGrid1.DataSource.DataSet.GotoBookmark(bm);
//ShowMessage('Данные успешно скопированы в буфер обмена.');
finally
DBGrid1.Visible := True;
end;
*}
end;
procedure TfMian.JumpToKey(Key: string);
var
i, n: Integer;
hWin: HWND;
ExecInfo: ShellExecuteInfoA;
// x3264: String; в данный момент закрыл
begin
hWin := FindWindowA(PChar('RegEdit_RegEdit'), nil);
if hWin = 0 then
{if Regedit doesn't run then we launch it}
begin
FillChar(ExecInfo, 60, #0);
with ExecInfo do
begin
cbSize := 60;
fMask := SEE_MASK_NOCLOSEPROCESS;
lpVerb := PChar('open');
lpFile := PChar('regedit.exe');
nShow := 1;
end;
ShellExecuteExA(@ExecInfo);
WaitForInputIdle(ExecInfo.hProcess, 200);
hWin := FindWindowA(PChar('RegEdit_RegEdit'), nil);
end;
ShowWindow(hWin, SW_SHOWNORMAL);
{ //
if rVetkaReestra.ItemIndex = 0 then
x3264:= 'SysTreeView32'
else if rVetkaReestra.ItemIndex = 1 then
x3264:= 'SysTreeView64';
// }
hWin := FindWindowExA(hWin, 0, PChar('SysTreeView32'), nil);
SetForegroundWindow(hWin);
i := 30;
repeat
SendMessageA(hWin, WM_KEYDOWN, VK_LEFT, 0);
Dec(i);
until i = 0;
Sleep(500);
SendMessageA(hWin, WM_KEYDOWN, VK_RIGHT, 0);
Sleep(500);
i := 1;
n := Length(Key);
repeat
if Key[i] = '\' then
begin
SendMessageA(hWin, WM_KEYDOWN, VK_RIGHT, 0);
Sleep(500);
end
else
SendMessageA(hWin, WM_CHAR, Integer(Key[i]), 0);
i := i + 1;
until i = n;
end;
procedure TfMian.rVetkaReestraSelectionChanged(Sender: TObject);
var
// MyList3: TStringListUTF8; // для хранения названий ключей реестра
i : Integer;
Str: string;
NameKey: string;
FullKey: String;
bitnost: String;
begin
if rVetkaReestra.ItemIndex = 0 then
begin
// MyRegistry:=TRegistry.Create;
FullKey:= 'Software\Microsoft\Windows\CurrentVersion\Uninstall\'
end
else if rVetkaReestra.ItemIndex = 1 then
begin
// MyRegistry:=TRegistry.Create(KEY_WOW64_64KEY);
FullKey:= 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\';
end;
//начало нового варианта
bitnost:=GetEnvironmentVariableUTF8('ProgramFiles(x86)');
if bitnost <> '' then
begin
MyRegistry2:=TRegistry.Create(KEY_WOW64_64KEY);
end
else
begin
MyRegistry2:=TRegistry.Create;
end;
ListBox1.Items.Clear;
MyList3:=TStringListUTF8.Create;
//MyRegistry:=TRegistry.Create(KEY_WOW64_32KEY);
with MyRegistry2 do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKeyReadOnly(FullKey);
GetKeyNames(MyList3);
CloseKey;
for i:=0 to MyList3.Count-1 do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKeyReadOnly(FullKey+
MyList3[i]);
Str:=ReadString('DisplayName');
if Str<>'' then
NameKey:=MyList3.Strings[i];
ListBox1.Items.Add(CP1251ToUTF8(NameKey));
CloseKey;
end;
end;
MyList3.Free;
end;
procedure TfMian.mBeginSerchClick(Sender: TObject);
var
MyList: TStringListUTF8; // для хранения названий ключей реестра
MyList2: TStringListUTF8;
MyList4: TStringListUTF8;
MyRegistry: TRegistry;
MassivAvtoStr: array of array of string;
s: string;
i :Integer;
p1:Integer;
p2:Integer;
p3:String;
FiltrStr: string;
Str: string;
N:Word; // было Integer // для записи в базу списка
bitnost:String;
begin
ProgressBar1.Position:=0;
ProgressBar1.Min := 0;
ProgressBar1.Max := 10;
lProgress.Caption:='Пожалуйста подождите';
Cursor:= crHourGlass;
bOpenKatPodrob.Enabled:=True;
cbZamenaPodrob.Enabled:=True;
bViewZamPodrob.Enabled:=True;
bSearch.Visible:=False; //скрываем кнопку начать поиск
// {* // очищаем старое содержимое
SQLQuery1.Close; // очиска таблицы в базе, в которую
SQLQuery1.SQL.Text := 'delete from install'; // записывается список программ
SQLQuery1.ExecSQL;
SQLTransaction1.CommitRetaining;
// *}
MyList2:=TStringListUTF8.Create;
// MyRegistry:=TRegistry.Create;
bitnost:=GetEnvironmentVariableUTF8('ProgramFiles(x86)');
if bitnost <> '' then
begin
MyRegistry:=TRegistry.Create(KEY_WOW64_64KEY);
end
else
begin
MyRegistry:=TRegistry.Create;
end;
ProgressBar1.StepBy(1);
MyList4:=TStringListUTF8.Create;
MyList:=TStringListUTF8.Create;
//Reg.KeyExists('\Software\key')
//if MyRegistry.KeyExists('SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall') then begin //IsWow64
// showmessage('ключ существует');
with MyRegistry do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKeyReadOnly('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\');
GetKeyNames(MyList);
CloseKey;
for i:=0 to MyList.Count-1 do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKeyReadOnly('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'+
MyList[i]);
Str:=ReadString('DisplayName');
if Str<>'' then
begin
// Memo1.Lines.Add(SysToUTF8(ReadString('DisplayName')));
MyList2.Add(CP1251ToUTF8(ReadString('DisplayName')));
MyList4.Add('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'+MyList[i]);
end;
CloseKey;
end;
RootKey:=HKEY_LOCAL_MACHINE;
OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Uninstall\');
GetKeyNames(MyList);
CloseKey;
for i:=0 to MyList.Count-1 do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+
MyList[i]);
Str:=ReadString('DisplayName');
if Str<>'' then
begin
// Memo1.Lines.Add(SysToUTF8(ReadString('DisplayName')));
MyList2.Add(CP1251ToUTF8(ReadString('DisplayName')));
MyList4.Add('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+MyList[i]);
end;
CloseKey;
end;
end;
ProgressBar1.StepBy(1);
// end
// {*
SQLQuery1.Close;
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('insert into install(text)'); // Запись полученного списка прог в базу
SQLQuery1.SQL.Add('Values (:pText)');
for N := 0 to MyList2.Count - 1 do
begin
SQLQuery1.ParamByName('pText').AsString := MyList2[N];
SQLQuery1.ExecSQL;
end;
SQLTransaction1.CommitRetaining;
ProgressBar1.StepBy(1);
//новый вариант
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Text:='select text from install';
SQLQuery1.Open;
SQLQuery1.First;
MyList2.clear; // пытался из базы получать список прог
while not SQLQuery1.Eof do
begin
MyList2.Add(SQLQuery1.FieldByName('text').AsString);
SQLQuery1.Next;
end;
SQLQuery1.Close;
ProgressBar1.StepBy(1);
//Пытаюсь фильтровать названия программ от версий
MyFiltrList:=TStringListUTF8.Create;
for N := 0 to MyList2.Count - 1 do
begin
FiltrStr:=MyList2[N];
UTF8Delete(FiltrStr, UTF8Pos(' CC', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' CS', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' cc', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' cs', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' CC 2015', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' CC 2016', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' CC 2017', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2015.1', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2015.2', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2015.3', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2015.4', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2015.5', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2016.1', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2016.2', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2016.3', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2016.4', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2016.5', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2017.1', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2017.2', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2017.3', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2017.4', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2017.5', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2015', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2016', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2017', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2007', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2008', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2009', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2010', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2011', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2012', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2013', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' 2014', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2015', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2016', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2017', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2007', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2008', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2009', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2010', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2011', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2012', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2013', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (2014', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v0', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v1', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v2', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v3', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v4', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v5', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v6', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v7', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v8', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' (v9', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v0', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v1', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v2', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v3', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v4', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v5', FiltrStr), UTF8Length(FiltrStr));
UTF8Delete(FiltrStr, UTF8Pos(' v6', FiltrStr), UTF8Length(FiltrStr));