-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathv5.3.0.2.pas
1761 lines (1567 loc) · 51.8 KB
/
v5.3.0.2.pas
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
# Based on GAppProxy 2.0.0 by Du XiaoGang <dugang.2008@gmail.com>
# Based on WallProxy 0.4.0 by Hust Moon <www.ehust@gmail.com>
# Contributor:
# Phus Lu <phus.lu@gmail.com>
# Hewig Xu <hewigovens@gmail.com>
# Ayanamist Yang <ayanamist@gmail.com>
# V.E.O <V.E.O@tom.com>
# Max Lv <max.c.lv@gmail.com>
# AlsoTang <alsotang@gmail.com>
# Christopher Meng <i@cicku.me>
# Yonsm Guo <YonsmGuo@gmail.com>
# Parkman <cseparkman@gmail.com>
# Ming Bai <mbbill@gmail.com>
# Bin Yu <yubinlove1991@gmail.com>
# lileixuan <lileixuan@gmail.com>
# Cong Ding <cong@cding.org>
# Zhang Youfu <zhangyoufu@gmail.com>
# Lu Wei <luwei@barfoo>
# Harmony Meow <harmony.meow@gmail.com>
# logostream <logostream@gmail.com>
# Rui Wang <isnowfy@gmail.com>
# Wang Wei Qiang <wwqgtxx@gmail.com>
# Felix Yan <felixonmars@gmail.com>
# Sui Feng <suifeng.me@qq.com>
# QXO <qxodream@gmail.com>
# Geek An <geekan@foxmail.com>
# Poly Rabbit <mcx_221@foxmail.com>
# oxnz <yunxinyi@gmail.com>
# Shusen Liu <liushusen.smart@gmail.com>
# Yad Smood <y.s.inside@gmail.com>
# Chen Shuang <cs0x7f@gmail.com>
# cnfuyu <cnfuyu@gmail.com>
# cuixin <steven.cuixin@gmail.com>
# s2marine0 <s2marine0@gmail.com>
# Toshio Xiang <snachx@gmail.com>
# Bo Tian <dxmtb@163.com>
# Virgil <variousvirgil@gmail.com>
# hub01 <miaojiabumiao@yeah.net>
# v3aqb <sgzz.cj@gmail.com>
# Oling Cat <olingcat@gmail.com>
# Meng Zhuo <mengzhuo1203@gmail.com>
# zwhfly <zwhfly@163.com>
# Hubertzhang <hubert.zyk@gmail.com>
# arrix <arrixzhou@gmail.com>
unit Unit1;
interface
// 枫叶香蕉v5X系列 源码
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TLhelp32, shellapi, StdCtrls, Types, ShlObj, ActiveX, ComObj,
Vcl.ExtCtrls, Vcl.Menus, Vcl.Imaging.jpeg, Vcl.ComCtrls, Registry,
Vcl.OleCtrls, SHDocVw, {该函数使用的单元} IOUtils, Wininet, StrUtils, MPlayer,
mmsystem, ToolWin, IniFiles, System.Zip, Vcl.Imaging.pngimage,
Vcl.Imaging.GIFImg, IdHashSHA, Typinfo,
Vcl.ImgList;
const
protect = 'C:\windows\kylin-proxy\proxy.ini';
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
WebBrowser1: TWebBrowser;
Timer1: TTimer;
N15: TMenuItem;
N9: TMenuItem;
TrayIcon1: TTrayIcon;
ImageList1: TImageList;
Timer2: TTimer;
BalloonHint1: TBalloonHint;
N5: TMenuItem;
N8: TMenuItem;
Timer3: TTimer;
Image1: TImage;
N6: TMenuItem;
N7: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure TrayIcon1Click(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure Image5MouseEnter(Sender: TObject);
procedure Image4MouseLeave(Sender: TObject);
procedure Image4Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image4MouseEnter(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N11DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N10DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N7DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N6DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N8DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N14DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure onionDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure N13Click(Sender: TObject);
procedure N12DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N22Click(Sender: TObject);
procedure N23Click(Sender: TObject);
procedure N24Click(Sender: TObject);
procedure N25Click(Sender: TObject);
procedure N18DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N19DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N20DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N21DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure O1Click(Sender: TObject);
procedure DNS2Click(Sender: TObject);
procedure DNS1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure O1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure DNS2DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N26Click(Sender: TObject);
procedure ASDL1Click(Sender: TObject);
procedure N27Click(Sender: TObject);
procedure N26DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure ASDL1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure N27DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure FormShow(Sender: TObject);
procedure N29Click(Sender: TObject);
procedure N30Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N31Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N41Click(Sender: TObject);
procedure RC41Click(Sender: TObject);
procedure aes256cfb1Click(Sender: TObject);
procedure bfcfb1Click(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure Label4Click(Sender: TObject);
procedure Label6Click(Sender: TObject);
procedure Label8Click(Sender: TObject);
procedure N6Click(Sender: TObject);
private
{ Private declarations }
procedure SysCommand(var SysMsg: TMessage); message WM_SYSCOMMAND;
public
{ Public declarations }
end;
function SetLayeredWindowAttributes(hwnd: HWND; crKey: Longint; bAlpha: byte;
dwFlags: longint): longint; stdcall; external user32; //函数声明
var
Form1: TForm1;
ee1, filename1: string; // 控制火狐浏览器启动
slist: TStringList; //存储文本文件内容
pstrarray: array of string; //数组
i, icount: integer;
mytitle, mytext: string;
createini: TiniFile; //------------
p, dynamic, ini, pp, newday: integer;
delappid, aa, c, d, self1, strHideFile, strdec: string;
ai, strfox, strgo, Temfox, Temgo: string;
icondata: tnotifyicondata;
myinifile, myinifile1: Tinifile;
e, b: string;
vi, a, ComA, ComB: integer;
filename: string;
MyStream: TMemIniFile;
//--------------
Reg: TRegistry;
proxya: string; //智能代理全局申明
SEX: integer;
info: INTERNET_PROXY_INFO;
StrEncrypt, StrEncrypt1: string;
protectFile: TFileStream;
buffer: array[0..86] of Byte = ($46, $00, $00, $00, $01, $00, $00, $00, $05,
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $1F, $00, $00, $00,
$68, $74, $74, $70, $3A, $2F, $2F, $31, $32, $37, $2E, $30, $2E, $30, $2E,
$31, $3A, $38, $30, $38, $36, $2F, $70, $72, $6F, $78, $79, $2E, $70, $61,
$63, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00);
buffer1: array[0..86] of Byte = ($46, $00, $00, $00, $02, $00, $00, $00, $01,
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $1F, $00, $00, $00,
$68, $74, $74, $70, $3A, $2F, $2F, $31, $32, $37, $2E, $30, $2E, $30, $2E,
$31, $3A, $38, $30, $38, $36, $2F, $70, $72, $6F, $78, $79, $2E, $70, $61,
$63, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00);
buffer2: array[0..107] of Byte = ($46, $00, $00, $00, $03, $00, $00, $00, $03,
$00, $00, $00, $0E, $00, $00, $00, $31, $32, $37, $2E, $30, $2E, $30, $2E,
$31, $3A, $38, $30, $38, $37, $07, $00, $00, $00, $3C, $6C, $6F, $63, $61,
$6C, $3E, $1F, $00, $00, $00, $68, $74, $74, $70, $3A, $2F, $2F, $31, $32,
$37, $2E, $30, $2E, $30, $2E, $31, $3A, $38, $30, $38, $36, $2F, $70, $72,
$6F, $78, $79, $2E, $70, $61, $63, $00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00, $00);
StrShaKylin, StrShaFirefox: string;
Strfirefox, Strfirefox1: string;
StrCountry: string;
StrUpdate: string;
Strkylinpath: string;
StrMyPath: string;
StrGetVolumeID: string;
StrEncryption: string;
StrEncryptionGet: string;
function GetFile_SHA1(const iFileName: string): string; // 获取文件SHA1
implementation
{$R *.dfm}
uses Unit2;
{$R hack.res}
function GetVolumeID: string;
var
vVolumeNameBuffer: array[0..255] of Char;
vVolumeSerialNumber: DWORD;
vMaximumComponentLength: DWORD;
vFileSystemFlags: DWORD;
vFileSystemNameBuffer: array[0..255] of Char;
begin
if GetVolumeInformation('c:\', vVolumeNameBuffer, SizeOf(vVolumeNameBuffer),
@vVolumeSerialNumber, vMaximumComponentLength, vFileSystemFlags,
vFileSystemNameBuffer, SizeOf(vFileSystemNameBuffer)) then
begin
Result := IntToHex(vVolumeSerialNumber, 8);
end;
end;
{自动适应屏幕 ---开始}
function DayOfWeek(const DateTime: TDateTime): Word; //判断星期几,偶数升级,基数sleep
begin
Result := DateTimeToTimeStamp(DateTime).Date mod 7 + 1;
end;
function PropertyExists(const AObject: TObject; const APropName: string):
Boolean;
var
PropInfo: PPropInfo;
begin
PropInfo := GetPropInfo(AObject.ClassInfo, APropName);
Result := Assigned(PropInfo);
end;
function GetObjectProperty(
const AObject: TObject;
const APropName: string
): TObject;
var
PropInfo: PPropInfo;
begin
Result := nil;
PropInfo := GetPropInfo(AObject.ClassInfo, APropName);
if Assigned(PropInfo) and
(PropInfo^.PropType^.Kind = tkClass) then
Result := GetObjectProp(AObject, PropInfo);
end;
procedure FitDeviceResolution(Sender: TForm);
const
OriWidth = 1280;
OriHeight = 800;
var
i: Integer;
j: Integer;
LocAnchors: array of TAnchors;
LocAlign: array of TAlign;
LocList: TList;
LocFontSize: Integer;
LocFont: TFont;
LocCmp: TComponent;
ScrResolutionRateH, ScrResolutionRateW, LocFontRate: Double;
begin
ScrResolutionRateH := Screen.Height / OriHeight;
ScrResolutionRateW := Screen.Width / OriWidth;
if Abs(ScrResolutionRateH - 1) < Abs(ScrResolutionRateW - 1) then
LocFontRate := ScrResolutionRateH
else
LocFontRate := ScrResolutionRateW;
LocList := TList.Create;
try
try
if (screen.width <> OriWidth) or (screen.Height <> OriHeight) then
begin
Sender.Scaled := False;
for i := Sender.ComponentCount - 1 downto 0 do
begin
LocCmp := Sender.Components[i];
if LocCmp is TControl then
LocList.Add(LocCmp);
if PropertyExists(LocCmp, 'FONT') then
begin
LocFont := TFont(GetObjectProperty(LocCmp, 'FONT'));
LocFontSize := Round(LocFontRate * LocFont.Size);
LocFont.Size := LocFontSize;
end;
end;
SetLength(LocAnchors, LocList.Count);
SetLength(LocAlign, LocList.Count);
for i := 0 to LocList.Count - 1 do
with TControl(LocList.Items[i]) do
begin
LocAnchors[i] := Anchors;
LocAlign[i] := Align;
Align := alNone;
Anchors := [akLeft, akTop];
end;
Sender.Top := Round(Sender.Top * ScrResolutionRateH);
Sender.Left := Round(Sender.Left * ScrResolutionRateW);
Sender.Height := Round(Sender.Height * ScrResolutionRateH);
Sender.Width := Round(Sender.Width * ScrResolutionRateW);
Sender.Font.size := Round(LocFontRate * Sender.Font.size);
for i := 0 to LocList.Count - 1 do
begin
with TControl(LocList.Items[i]) do
begin
Top := Round(Top * ScrResolutionRateH);
Left := Round(Left * ScrResolutionRateW);
Height := Round(height * ScrResolutionRateH);
Width := Round(width * ScrResolutionRateW);
end;
end;
for i := 0 to LocList.Count - 1 do
TControl(LocList.Items[i]).Align := LocAlign[i];
for i := 0 to LocList.Count - 1 do
TControl(LocList.Items[i]).Anchors := LocAnchors[i];
end;
except
MessageDlg(LocCMP.Name, mtInformation, [mbOK], 0);
end;
finally
LocList.Free;
end;
end;
{自动适应屏幕 ---结束}
function GetFile_SHA1(const iFileName: string): string; //Checksum hash value for firefox
var
SHA1: TIdHashSHA1;
fileStream: TMemoryStream;
begin
SHA1 := TIdHashSHA1.Create;
fileStream := TMemoryStream.Create;
try
fileStream.LoadFromFile(iFileName);
Result := SHA1.HashStreamAsHex(fileStream);
finally
fileStream.Free;
SHA1.Free;
end;
end;
function ADSLsetupTOCANCEL(const bEnabled: boolean = True): boolean;
var
hKey1: HKEY;
i: integer;
retCode, size: Cardinal;
Key, Value: array[0..255] of char;
strkey: string;
begin
Result := False;
Reg := TRegistry.Create;
RegOpenKeyEx(HKEY_CURRENT_USER,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections',
0,
KEY_READ, hKey1);
i := 0;
repeat
size := 1024;
retCode := RegEnumValue(hKey1, i, Key, size, nil, nil, nil, nil);
if retCode = ERROR_SUCCESS then
begin
reg := tregistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
REG.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections', true);
i := i + 1;
// Memo1.Lines.Add(Key);
size := 1024;
strkey := string(key);
Reg.WriteBinaryData(strkey, buffer1[0], Length(buffer));
end;
until (retCode <> ERROR_SUCCESS);
RegCloseKey(hKey1);
// showmessage('拨号取消成功!') ;
sleep(50);
Result := True;
reg.CloseKey;
reg.free;
end;
function ADSLsetupglobal(const bEnabled: boolean = True): boolean; //setup global Mode for adsl
var
hKey1: HKEY;
i: integer;
retCode, size: Cardinal;
Key, Value: array[0..255] of char;
strkey: string;
begin
Result := False;
Reg := TRegistry.Create;
RegOpenKeyEx(HKEY_CURRENT_USER,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections',
0,
KEY_READ, hKey1);
i := 0;
repeat
size := 1024;
retCode := RegEnumValue(hKey1, i, Key, size, nil, nil, nil, nil);
if retCode = ERROR_SUCCESS then
begin
reg := tregistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
REG.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections', true);
i := i + 1;
// Memo1.Lines.Add(Key);
size := 1024;
strkey := string(key);
Reg.WriteBinaryData(strkey, buffer2[0], Length(buffer));
end;
until (retCode <> ERROR_SUCCESS);
RegCloseKey(hKey1);
//showmessage('拨号设置成功!') ;
SLEEP(50);
Result := True;
reg.CloseKey;
reg.free;
end;
function ADSLsetup(const bEnabled: boolean = True): boolean; //setup smart Mode at adsl
var
hKey1: HKEY;
i: integer;
retCode, size: Cardinal;
Key, Value: array[0..255] of char;
strkey: string;
begin
Result := False;
Reg := TRegistry.Create;
RegOpenKeyEx(HKEY_CURRENT_USER,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections',
0,
KEY_READ, hKey1);
i := 0;
repeat
size := 1024;
retCode := RegEnumValue(hKey1, i, Key, size, nil, nil, nil, nil);
if retCode = ERROR_SUCCESS then
begin
reg := tregistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
REG.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections', true);
i := i + 1;
// Memo1.Lines.Add(Key);
size := 1024;
strkey := string(key);
Reg.WriteBinaryData(strkey, buffer[0], Length(buffer));
end;
until (retCode <> ERROR_SUCCESS);
RegCloseKey(hKey1);
//showmessage('拨号设置成功!') ;
SLEEP(50);
Result := True;
reg.CloseKey;
reg.free;
end;
function StrPosCount(subs: string; source: string): integer; //统计字符串出现的次数
var
Str: string;
begin
Result := 0;
str := source;
while Pos(Subs, Str) <> 0 do
begin
Delete(Str, Pos(Subs, Str), Length(Subs));
Inc(Result);
end;
end;
{===============================================================================
函数名: Rc4_StrEncrypt()
描 述: RC4 Based string encryption
参 数: i_Encrypt ——为 1 是加密, 0 是解密(integer类型);
s_EncryptText ——待加密(解密)的字符串(string类型);
s_EncryptPassword ——加密(解密)的密码(string类型);
i_EncryptLevel ——加密级别(范围:1--10;integer类型))
翻译: 吴间道
QQ: 93331961
=============================================================================== }
function Rc4(i_Encrypt: integer; s_EncryptText,
s_EncryptPassword: string; i_EncryptLevel: integer = 1): string;
var
v_EncryptModified, v_EncryptCipher, v_EncryptCipherBy: string;
i_EncryptCountA, i_EncryptCountB, i_EncryptCountC, i_EncryptCountD,
i_EncryptCountE, i_EncryptCountF, i_EncryptCountG, i_EncryptCountH,
v_EncryptSwap: integer;
av_EncryptBox: array[0..256, 0..2] of integer;
begin
if (i_Encrypt <> 0) and (i_Encrypt <> 1) then
begin
result := '';
end
else if (s_EncryptText = '') or (s_EncryptPassword = '') then
begin
result := '';
end
else
begin
if (i_EncryptLevel <= 0) or (Int(i_EncryptLevel) <> i_EncryptLevel) then
i_EncryptLevel := 1;
if Int(i_EncryptLevel) > 10 then i_EncryptLevel := 10;
if i_Encrypt = 1 then
begin
for i_EncryptCountF := 0 to i_EncryptLevel do
begin
i_EncryptCountG := 0;
i_EncryptCountH := 0;
v_EncryptModified := '';
for i_EncryptCountG := 1 to Length(s_EncryptText) do
begin
if i_EncryptCountH = Length(s_EncryptPassword) then
begin
i_EncryptCountH := 1;
end
else
begin
inc(i_EncryptCountH);
end;
v_EncryptModified := v_EncryptModified +
Chr(Ord(s_EncryptText[i_EncryptCountG]) xor
Ord(s_EncryptPassword[i_EncryptCountH]) xor 255);
end;
s_EncryptText := v_EncryptModified;
i_EncryptCountA := 0;
i_EncryptCountB := 0;
i_EncryptCountC := 0;
i_EncryptCountD := 0;
i_EncryptCountE := 0;
v_EncryptCipherBy := '';
v_EncryptCipher := '';
v_EncryptSwap := 0;
for i_EncryptCountA := 0 to 255 do
begin
av_EncryptBox[i_EncryptCountA, 1] :=
Ord(s_EncryptPassword[i_EncryptCountA mod Length(s_EncryptPassword)
+
1]);
av_EncryptBox[i_EncryptCountA, 0] := i_EncryptCountA;
end;
for i_EncryptCountA := 0 to 255 do
begin
i_EncryptCountB := (i_EncryptCountB + av_EncryptBox[i_EncryptCountA][0]
+ av_EncryptBox[i_EncryptCountA][1]) mod 256;
v_EncryptSwap := av_EncryptBox[i_EncryptCountA][0];
av_EncryptBox[i_EncryptCountA][0] :=
av_EncryptBox[i_EncryptCountB][0];
av_EncryptBox[i_EncryptCountB][0] := v_EncryptSwap;
end;
for i_EncryptCountA := 1 to Length(s_EncryptText) do
begin
i_EncryptCountC := (i_EncryptCountC + 1) mod 256;
i_EncryptCountD := (i_EncryptCountD +
av_EncryptBox[i_EncryptCountC][0]) mod 256;
i_EncryptCountE := av_EncryptBox[(av_EncryptBox[i_EncryptCountC][0] +
av_EncryptBox[i_EncryptCountD][0]) mod 256][0];
v_EncryptCipherBy := inttostr(Ord(s_EncryptText[i_EncryptCountA]) xor
i_EncryptCountE);
v_EncryptCipher := v_EncryptCipher +
IntToHex(strtoint(v_EncryptCipherBy), 2);
end;
s_EncryptText := v_EncryptCipher;
end;
end
else
begin
for i_EncryptCountF := 0 to i_EncryptLevel do
begin
i_EncryptCountB := 0;
i_EncryptCountC := 0;
i_EncryptCountD := 0;
i_EncryptCountE := 0;
v_EncryptCipherBy := '';
v_EncryptCipher := '';
v_EncryptSwap := 0;
for i_EncryptCountA := 0 to 255 do
begin
av_EncryptBox[i_EncryptCountA, 1] :=
Ord(s_EncryptPassword[i_EncryptCountA mod Length(s_EncryptPassword)
+
1]);
av_EncryptBox[i_EncryptCountA, 0] := i_EncryptCountA;
end;
for i_EncryptCountA := 0 to 255 do
begin
i_EncryptCountB := (i_EncryptCountB + av_EncryptBox[i_EncryptCountA, 0]
+ av_EncryptBox[i_EncryptCountA, 1]) mod 256;
v_EncryptSwap := av_EncryptBox[i_EncryptCountA, 0];
av_EncryptBox[i_EncryptCountA, 0] := av_EncryptBox[i_EncryptCountB,
0];
av_EncryptBox[i_EncryptCountB, 0] := v_EncryptSwap;
end;
for i_EncryptCountA := 1 to Length(s_EncryptText) do
begin
if (i_EncryptCountA mod 2) <> 0 then
begin
i_EncryptCountC := ((i_EncryptCountC + 1) mod 256);
i_EncryptCountD := ((i_EncryptCountD +
av_EncryptBox[i_EncryptCountC, 0]) mod 256);
i_EncryptCountE := av_EncryptBox[((av_EncryptBox[i_EncryptCountC, 0]
+ av_EncryptBox[i_EncryptCountD, 0]) mod 256), 0];
v_EncryptCipherBy := inttostr(StrToInt64('$' +
s_EncryptText[i_EncryptCountA] + s_EncryptText[i_EncryptCountA +
1])
xor i_EncryptCountE);
v_EncryptCipher := v_EncryptCipher +
Chr(strtoint(v_EncryptCipherBy));
end;
end;
s_EncryptText := v_EncryptCipher;
i_EncryptCountG := 0;
i_EncryptCountH := 0;
v_EncryptModified := '';
for i_EncryptCountG := 1 to Length(s_EncryptText) do
begin
if i_EncryptCountH = Length(s_EncryptPassword) then
begin
i_EncryptCountH := 1;
end
else
begin
i_EncryptCountH := i_EncryptCountH + 1;
end;
v_EncryptModified := v_EncryptModified +
Chr((Ord(s_EncryptText[i_EncryptCountG]) xor
Ord(s_EncryptPassword[i_EncryptCountH]) xor 255));
end;
s_EncryptText := v_EncryptModified;
end;
end;
result := s_EncryptText;
end;
end;
function DeleteDirectory(NowPath: string): Boolean; // 删除整个目录
var
search: TSearchRec;
ret: integer;
key: string;
begin
if NowPath[Length(NowPath)] <> '\' then
NowPath := NowPath + '\';
key := NowPath + '*.*';
ret := findFirst(key, faanyfile, search);
while ret = 0 do
begin
if ((search.Attr and fadirectory) = fadirectory) then
begin
if (search.Name <> '.') and (search.name <> '..') then
DeleteDirectory(NowPath + search.name);
end
else
begin
if ((search.Attr and fadirectory) <> fadirectory) then
begin
deletefile(NowPath + search.name);
end;
end;
ret := FindNext(search);
end;
findClose(search);
removedir(NowPath);
result := True;
end;
procedure TForm1.SysCommand(var SysMsg: TMessage); //最小化 隐藏到 托盘
begin
case SysMsg.WParam of
SC_CLOSE:
begin
// 当最小化时
SetWindowPos(Application.Handle, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_HIDEWINDOW);
form1.hide; // 在任务栏隐藏程序
end;
else
inherited;
case SysMsg.WParam of
SC_MINIMIZE:
begin
// 当最小化时
SetWindowPos(Application.Handle, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_HIDEWINDOW);
form1.hide; // 在任务栏隐藏程序
end;
else
inherited;
end;
end;
end;
function certDisabledProxyEnable(const key: boolean = True): boolean; //取消证书警告
var
Reg: TRegistry;
info: INTERNET_PROXY_INFO;
begin
Result := False;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if
Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Internet Settings',
false) then
begin
Reg.WriteInteger('WarnonBadCertRecving', integer(key));
InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info));
InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0);
Reg.CloseKey;
end;
except
Reg.Free;
end;
end;
//------------------------------------------------ 取消证书警告
procedure cryptFile(srcFile, dstFile: TFilename); //加密函数
var
srcf, dstf: file of byte;
buf: byte;
begin
assign(srcf, srcfile);
assign(dstf, dstfile);
reset(srcf);
rewrite(dstf);
while not eof(srcf) do
begin
read(srcf, buf);
buf := buf + 21; //这里可以修改成其他的数值
write(dstf, buf);
end;
closefile(srcf);
closefile(dstf);
end;
procedure decryptFile(srcFile, dstFile: TFilename); //解密函数
var
srcf, dstf: file of byte;
buf: byte;
begin
assign(srcf, srcfile);
assign(dstf, dstfile);
reset(srcf);
rewrite(dstf);
while not eof(srcf) do
begin
read(srcf, buf);
buf := buf - 21; //这里可以作相应修改
write(dstf, buf);
end;
closefile(srcf);
closefile(dstf);
end;
function CreateShortcut(Exe: string; Lnk: string = ''; Dir: string = ''; ID:
Integer = -1): Boolean;
var
IObj: IUnknown;
ILnk: IShellLink;
IPFile: IPersistFile;
PIDL: PItemIDList;
InFolder: array[0..MAX_PATH] of Char;
LinkFileName: WideString;
begin
Result := False;
if not FileExists(Exe) then Exit;
if Lnk = '' then Lnk := ChangeFileExt(ExtractFileName(Exe), '');
IObj := CreateComObject(CLSID_ShellLink);
ILnk := IObj as IShellLink;
ILnk.SetPath(PChar(Exe));
ILnk.SetWorkingDirectory(PChar(ExtractFilePath(Exe)));
if (Dir = '') and (ID = -1) then ID := CSIDL_DESKTOP;
if ID > -1 then
begin
SHGetSpecialFolderLocation(0, ID, PIDL);
SHGetPathFromIDList(PIDL, InFolder);
LinkFileName := Format('%s\%s.lnk', [InFolder, Lnk]);
end
else
begin
Dir := ExcludeTrailingPathDelimiter(Dir);
if not DirectoryExists(Dir) then Exit;
LinkFileName := Format('%s\%s.lnk', [Dir, Lnk]);
end;
IPFile := IObj as IPersistFile;
if IPFile.Save(PWideChar(LinkFileName), False) = 0 then Result := True;
end; {CreateShortcut 函数结束}
//-----------------------------------------------------
procedure ExtractRes(ResType, ResName, ResNewName: string);
var
Res: TResourceStream;
begin //释放资源文件library.ini
Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
Res.SavetoFile(ResNewName);
Res.Free;
end; //这个方法意思是释放资源文件 有三个参数
//一个资源类型 2 资源名字 生成资源的名字
//----------------------------------------------------
procedure RefreshControl(Control: TControl); ///解决 托盘重现显示窗体控件 无法重画的问题
var
i: integer;
begin
Control.Invalidate;
if Control is TWinControl then
for i := 0 to TWinControl(Control).ControlCount - 1 do
RefreshControl(TWinControl(Control).Controls[i]);
end;
//----------------------------------------------------------
function FindProcess(AFileName: string): boolean;
var
hSnapshot: THandle; //用于获得进程列表
lppe: TProcessEntry32; //用于查找进程
Found: Boolean; //用于判断进程遍历是否完成
begin
Result := False;
hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //获得系统进程列表
lppe.dwSize := SizeOf(TProcessEntry32); //在调用Process32First API之前,需要初始化lppe记录的大小
Found := Process32First(hSnapshot, lppe); //将进程列表的第一个进程信息读入ppe记录中
while Found do
begin
if ((UpperCase(ExtractFileName(lppe.szExeFile)) = UpperCase(AFileName)) or
(UpperCase(lppe.szExeFile) = UpperCase(AFileName))) then
begin
Result := True;
end;
Found := Process32Next(hSnapshot, lppe); //将进程列表的下一个进程信息读入lppe记录中
end;
end;
//----------------------------------------------------------------------------------------------------------
function CheckTask(ExeFileName: string): Boolean;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result := False;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName))
or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then
result := True;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
end;
function KillTask(ExeFileName: string): integer;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOLean;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
Result := Integer(TerminateProcess(
OpenProcess(PROCESS_TERMINATE,
BOOL(0),
FProcessEntry32.th32ProcessID),
0));
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
//-----------------------------------------------------------------------------
function ChangeProxy(const Proxy, Port, ByPass: string; const bEnabled: boolean
= True): boolean;
var
reg: TreGIStry;
info: INTERNET_PROXY_INFO;
Fproxy: string;
begin
Result := False;
FProxy := Format('%s:%s', [Proxy, Port]);
reg := TreGIStry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
if
reg.OpenKey('\Software\Microsoft\windows\CurrentVersion\Internet Settings',
True) then
begin
reg.Writestring('ProxyServer', Fproxy);
reg.WriteInteger('ProxyEnable', integer(bEnabled));
info.dwaccessType := INTERNET_OPEN_TYPE_PROXY;
info.lpszProxy := PAnsiChar(proxy);
info.lpszProxyBypass := PAnsiChar(ByPass);
InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info));
InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0);
// InternetSetOption(nil, INTERNET_OPTION_REFRESH, nil, 0);
// Sendmessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
Result := True;
end
finally
reg.CloseKey;
reg.free;
end;
end;
//-----------------------------------------------------------------------------
function dDisabledProxyEnable(const key: boolean = True): boolean; //取消代理
var
Reg: TRegistry;
info: INTERNET_PROXY_INFO;
begin
Result := False;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if
Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Internet Settings',
false) then
begin
Reg.WriteInteger('ProxyEnable', integer(key));
InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info));
InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0);
Reg.CloseKey;
end;
except
Reg.Free;
end;
end;
//------------------------------------------------ ChangeProxy 智能代理模式,写注册表