-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.pas
More file actions
627 lines (539 loc) · 18.4 KB
/
Unit1.pas
File metadata and controls
627 lines (539 loc) · 18.4 KB
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
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, my_iphlpapi, Winsock, Winapi.IpHlpApi, Winapi.IpRtrMib,
Vcl.Menus, Vcl.ExtCtrls, Generics.Collections, my_ifdef, Winapi.IpTypes,
my_IPTypes, ShellAPI, System.ImageList, Vcl.ImgList, Registry,
System.Notification, Form_Popup, Vcl.ComCtrls, Form_About, config, Form_Config,
Form_PingGraph, Form_PWGen, def_NDIS_Interface_Types, Winapi.ShlObj,
WinApi.KnownFolders, Winapi.ActiveX;
type
TIPInterface = record
addr:Array Of DWORD;
mask:Array Of DWORD;
dns:Array Of DWORD;
gateway:DWORD;
name:string;
OperStatus:IF_OPER_STATUS;
DHCP:Boolean;
end;
TForm1 = class(TForm)
TrayIcon1: TTrayIcon;
pmTrayIcon: TPopupMenu;
Exit1: TMenuItem;
NetworkConnections1: TMenuItem;
imgTrayIcons: TImageList;
tvInterfaces: TTreeView;
MainMenu1: TMainMenu;
Refresh1: TMenuItem;
Exit2: TMenuItem;
N1: TMenuItem;
About1: TMenuItem;
Menu1: TMenuItem;
N2: TMenuItem;
Networkconnections2: TMenuItem;
Settings1: TMenuItem;
N3: TMenuItem;
Settings2: TMenuItem;
SwissArmyKnife1: TMenuItem;
menuReleaseRenew: TMenuItem;
imgTrayMenuIcons: TImageList;
Connectionproperties1: TMenuItem;
Pinggraph1: TMenuItem;
menuPWGen: TMenuItem;
menuHostsfile: TMenuItem;
procedure CheckTrayIcon;
procedure ConnectionPropertiesOnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure TrayIcon1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormDestroy(Sender: TObject);
procedure NetworkConnections1Click(Sender: TObject);
procedure WndProc(var msg:TMessage);override;
procedure Button1Click(Sender: TObject);
procedure Refresh1Click(Sender: TObject);
procedure ReloadConnectionProperties;
procedure ReloadTools;
procedure About1Click(Sender: TObject);
procedure Settings1Click(Sender: TObject);
procedure ToolOnClick(Sender: TObject);
procedure menuReleaseRenewClick(Sender: TObject);
procedure Pinggraph1Click(Sender: TObject);
procedure menuPWGenClick(Sender: TObject);
procedure TrayIcon1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure menuHostsfileClick(Sender: TObject);
private
{ Private-Deklarationen }
IpChangeHandle:THandle;
CloseMe:Boolean;
AddressDict:TDictionary<NET_IFINDEX, TIPInterface>;
procedure FillTreeView;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function BytesToMAC(b:Array Of Byte):string;
var
I:Integer;
begin
Result := '';
for I := 0 to 5 do begin
Result := Result + IntToHex(b[I], 2);
if (I <> 5) then Result := Result + ':';
end;
end;
function OperStatusToStr(OperStatus:IF_OPER_STATUS):string;
begin
case OperStatus of
IfOperStatusUp: begin
Result := 'IfOperStatusUp (1)';
end;
IfOperStatusDown: begin
Result := 'IfOperStatusDown (2)';
end;
IfOperStatusTesting: begin
Result := 'IfOperStatusTesting (3)';
end;
IfOperStatusUnknown: begin
Result := 'IfOperStatusUnknown (4)';
end;
IfOperStatusDormant: begin
Result := 'IfOperStatusDormant (5)';
end;
IfOperStatusNotPresent: begin
Result := 'IfOperStatusNotPresent (6)';
end;
IfOperStatusLowerLayerDown: begin
Result := 'IfOperStatusLowerLayerDown (7)';
end else begin
Result := 'Unknown status (' + IntToStr(Integer(OperStatus)) + '), check MSDN!';
end;
end;
end;
procedure FillIPInterfaceInfo(luid:Int64; var info:TIPInterface);
var
buffer:Array Of Byte;
size:ULONG;
c:Cardinal;
struct:PIP_ADAPTER_ADDRESSES;
DnsStruct:PIP_ADAPTER_DNS_SERVER_ADDRESS;
const
flags =
GAA_FLAG_INCLUDE_GATEWAYS or
GAA_FLAG_SKIP_UNICAST or
GAA_FLAG_SKIP_ANYCAST or
GAA_FLAG_SKIP_MULTICAST
;
begin
info.name := 'Adaptername';
size := 0;
c := GetAdaptersAddresses(AF_INET, flags, nil, @buffer[0], @size);
if (c <> ERROR_BUFFER_OVERFLOW) then Exit;
SetLength(buffer, size);
c := GetAdaptersAddresses(AF_INET, flags, nil, @buffer[0], @size);
if (c <> ERROR_SUCCESS) then Exit;
struct := @buffer[0];
while True do begin
if (struct.Luid.Value = luid) then begin
info.name := struct.FriendlyName;
if (struct.FirstGatewayAddress <> nil) then begin
info.gateway := struct.FirstGatewayAddress.Address.lpSockaddr.sin_addr.S_addr;
end else info.gateway := 0;
info.OperStatus := struct.OperStatus;
info.DHCP := (struct.Flags OR IP_ADAPTER_DHCP_ENABLED) = struct.Flags;
DnsStruct := struct.FirstDnsServerAddress;
while (DnsStruct <> nil) do begin
SetLength(info.dns, Length(info.dns)+1);
info.dns[Length(info.dns)-1] := DnsStruct^.Address.lpSockaddr.sin_addr.S_addr;
DnsStruct := DnsStruct.Next;
end;
Exit;
end;
if (struct.Next = nil) then begin
break;
end else begin
struct := struct.Next;
end;
end;
end;
procedure MainThread_IpChangeCallback(CallerContext:PVOID; Row:PMIB_IPINTERFACE_ROW; NotificationType:MIB_NOTIFICATION_TYPE);
var
table:MIB_IPADDRTABLE;
c, count:Cardinal;
buffer:Array Of Byte;
i:Integer;
index:NET_IFINDEX;
changed:Boolean;
newInterface:TIPInterface;
masklen:UINT8;
dhcpText, balloonHint:string;
begin
index := Row.InterfaceIndex;
FillIPInterfaceInfo(Row.InterfaceLuid.Value, newInterface);
changed := False;
count := 0;
c := GetIpAddrTable(@table, count, False);
if (c <> ERROR_INSUFFICIENT_BUFFER) then Exit;
SetLength(buffer, count);
c := GetIpAddrTable(@buffer[0], count, False);
if (c <> NO_ERROR) then Exit;
for I := 0 to PMIB_IPADDRTABLE(@buffer[0]).dwNumEntries-1 do begin
if PMIB_IPADDRROW(@buffer[4+SizeOf(MIB_IPADDRROW)*i]).dwIndex = index then begin
SetLength(newInterface.addr, Length(newInterface.addr)+1);
SetLength(newInterface.mask, Length(newInterface.mask)+1);
newInterface.addr[Length(newInterface.addr)-1] := PMIB_IPADDRROW(@buffer[4+SizeOf(MIB_IPADDRROW)*i]).dwAddr;
newInterface.mask[Length(newInterface.mask)-1] := PMIB_IPADDRROW(@buffer[4+SizeOf(MIB_IPADDRROW)*i]).dwMask;
end;
end;
if (Form1.AddressDict.ContainsKey(index)) then begin
if (Length(Form1.AddressDict[index].addr) <> Length(newInterface.addr)) then begin
changed := True;
end else begin
for I := 0 to Length(newInterface.addr)-1 do begin
if (Form1.AddressDict[index].addr[I] <> newInterface.addr[I]) then begin
changed := True;
break;
end;
if (Form1.AddressDict[index].mask[I] <> newInterface.mask[I]) then begin
changed := True;
break;
end;
end;
end;
Form1.AddressDict.AddOrSetValue(index, newInterface);
end else begin
changed := True;
Form1.AddressDict.AddOrSetValue(index, newInterface);
end;
if (changed) then begin
// Mainform refresh on changed interfaces
Form1.Refresh1Click(Form1);
// Check if user want's a popup for this interface, exit if not
if (globalConfig.TestInterfaceRegex(newInterface.name)) then
Exit;
OutputDebugString(PChar('Interface changed: ' + newInterface.name + ' | Status: ' + IntToStr(Integer(newInterface.OperStatus))));
if (newInterface.OperStatus = IF_OPER_STATUS.IfOperStatusDown) then begin
PopupForm.Popup(newInterface.name, 'Disconnected');
end else begin
if (newInterface.DHCP) then begin
dhcpText := 'DHCP';
end else begin
dhcpText := 'static';
end;
balloonHint := 'IPs: (' + dhcpText + ')'#13#10;
for I := 0 to Length(newInterface.addr)-1 do begin
ConvertIpv4MaskToLength(newInterface.mask[I], masklen);
balloonHint := balloonHint + string(inet_ntoa(in_addr(newInterface.addr[I]))) + #9' /' + IntToStr(masklen) + #13#10;
end;
balloonHint := balloonHint + #13#10'DNS: '#13#10;
for I := 0 to Length(newInterface.dns)-1 do begin
balloonHint := balloonHint + string(inet_ntoa(in_addr(newInterface.dns[I]))) + #13#10;
end;
PopupForm.Popup(newInterface.name,
balloonHint + #13#10 +
'Gateway:'#13#10 + string(inet_ntoa(in_addr(newInterface.gateway)))
);
end;
end;
end;
procedure IpChangeCallback(CallerContext:PVOID; Row:PMIB_IPINTERFACE_ROW; NotificationType:MIB_NOTIFICATION_TYPE); stdcall;
begin
// Synchronize should never be called by the main thread, can cause infinite loops.
if (GetCurrentThreadId = MainThreadID) then exit;
// This callback is not called by the main thread, we call synchronize to make the main thread do the work.
// Causes trouble if you don't ;)
TThread.Synchronize(nil, procedure begin MainThread_IpChangeCallback(CallerContext, Row, NotificationType); end);
end;
procedure TForm1.About1Click(Sender: TObject);
begin
FormAbout.Show;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Exit;
end;
procedure TForm1.CheckTrayIcon;
var
reg:TRegistry;
lightTheme:Boolean;
icon:TIcon;
iconIndex:Integer;
begin
if (LOBYTE(LOWORD(GetVersion)) = 10) then begin // If Win10
reg := TRegistry.Create;
try
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Themes\Personalize');
lightTheme := reg.ReadBool('SystemUsesLightTheme');
if lightTheme then begin
iconIndex := 1;
end else begin
iconIndex := 0;
end;
except
lightTheme := False;
iconIndex := 0;
end;
reg.Free;
end else begin
lightTheme := True;
iconIndex := 2; // Colored Win7 style
end;
PopupForm.DarkMode := not lightTheme;
icon := TIcon.Create;
imgTrayIcons.GetIcon(iconIndex, icon);
TrayIcon1.Icon := icon;
icon.Free;
end;
procedure TForm1.ConnectionPropertiesOnClick(Sender: TObject);
var
item:TMenuItem;
begin
item := Sender as TMenuItem;
ShellExecute(
0,
nil,
'rundll32.exe',
PChar('net_properties.dll,ShowConnectionProperties ' + item.Caption),
PChar(ExtractFilePath(Application.ExeName)),
SW_SHOWNORMAL
);
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
CloseMe := True;
Close;
end;
procedure TForm1.FillTreeView;
var
c, count:Cardinal;
AddrBuffer, IfBuffer:Array Of Byte;
I:Integer;
Addresses:PIP_ADAPTER_ADDRESSES;
node, childNode:TTreeNode;
dns:PIP_ADAPTER_DNS_SERVER_ADDRESS;
masklen:Byte;
const
flags =
GAA_FLAG_INCLUDE_GATEWAYS or
GAA_FLAG_SKIP_UNICAST or
GAA_FLAG_SKIP_ANYCAST or
GAA_FLAG_SKIP_MULTICAST
;
begin
// Get IP Address Table, iterated later
count := 0;
c := GetIpAddrTable(@AddrBuffer[0], count, False);
if (c <> ERROR_INSUFFICIENT_BUFFER) then Exit;
SetLength(AddrBuffer, count);
c := GetIpAddrTable(@AddrBuffer[0], count, False);
if (c <> NO_ERROR) then Exit;
// Get Adapters
count := 0;
c := GetAdaptersAddresses(AF_INET, flags, nil, @IfBuffer[0], @count);
if (c <> ERROR_BUFFER_OVERFLOW) then Exit;
SetLength(IfBuffer, count);
c := GetAdaptersAddresses(AF_INET, flags, nil, @IfBuffer[0], @count);
if (c <> ERROR_SUCCESS) then Exit;
Addresses := @IfBuffer[0];
while (Addresses <> nil) do begin
node := tvInterfaces.Items.Add(nil, Addresses.FriendlyName);
tvInterfaces.Items.AddChild(node, 'Description: ' + Addresses.Description);
tvInterfaces.Items.AddChild(node, 'MAC Address: ' + BytesToMAC(Addresses.PhysicalAddress));
tvInterfaces.Items.AddChild(node, 'DHCP enabled: ' + BoolToStr((Addresses.Flags OR IP_ADAPTER_DHCP_ENABLED) = Addresses.Flags, True));
childNode := tvInterfaces.Items.AddChild(node, 'IPs');
for I := 0 to PMIB_IPADDRTABLE(@AddrBuffer[0]).dwNumEntries-1 do begin
if PMIB_IPADDRROW(@AddrBuffer[4+SizeOf(MIB_IPADDRROW)*i]).dwIndex = Addresses.Union.IfIndex then begin
ConvertIpv4MaskToLength(PMIB_IPADDRROW(@AddrBuffer[4+SizeOf(MIB_IPADDRROW)*i]).dwMask, masklen);
tvInterfaces.Items.AddChild(childNode,
'IP: ' + string(inet_ntoa(in_addr(PMIB_IPADDRROW(@AddrBuffer[4+SizeOf(MIB_IPADDRROW)*i]).dwAddr))) +
' | Mask: ' + string(inet_ntoa(in_addr(PMIB_IPADDRROW(@AddrBuffer[4+SizeOf(MIB_IPADDRROW)*i]).dwMask))) +
' /' + IntToStr(masklen)
);
end;
end;
if (childNode.HasChildren = False) then childNode.Free;
if (Addresses.FirstGatewayAddress <> nil) then
tvInterfaces.Items.AddChild(node, 'Default gateway: ' + inet_ntoa(Addresses.FirstGatewayAddress.Address.lpSockaddr.sin_addr));
if (Addresses.FirstDnsServerAddress <> nil) then begin
childNode := tvInterfaces.Items.AddChild(node, 'DNS servers');
dns := Addresses.FirstDnsServerAddress;
while (dns <> nil) do begin
tvInterfaces.Items.AddChild(childNode, string(inet_ntoa(dns.Address.lpSockaddr.sin_addr)));
dns := dns.Next;
end;
end;
if (Addresses.Dhcpv4Server.lpSockaddr <> nil) then
tvInterfaces.Items.AddChild(node, 'DHCP server: ' + string(inet_ntoa(Addresses.Dhcpv4Server.lpSockaddr.sin_addr)));
tvInterfaces.Items.AddChild(node, 'Interface type: ' + InterfaceTypeToStr(Addresses.IfType));
tvInterfaces.Items.AddChild(node, 'Operational status: ' + OperStatusToStr(Addresses.OperStatus));
if (Addresses.DnsSuffix <> '') then
tvInterfaces.Items.AddChild(node, 'DNS suffix: ' + Addresses.DnsSuffix);
// Only expand "interesting" nodes, filtered by config
if (globalConfig.TestInterfaceRegex(Addresses.FriendlyName) = False) then
node.Expand(True);
Addresses := Addresses.Next;
end;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := CloseMe;
Hide;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
AddressDict := TDictionary<NET_IFINDEX, TIPInterface>.Create;
CloseMe := False;
ReloadTools;
ReloadConnectionProperties;
NotifyIpInterfaceChange(AF_INET, @IpChangeCallback, nil, False, IpChangeHandle);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
AddressDict.Free;
end;
procedure TForm1.menuHostsfileClick(Sender: TObject);
var
path: PChar;
begin
if SHGetKnownFolderPath(FOLDERID_System, KF_FLAG_DEFAULT, 0, path) = S_OK then begin
ShellExecute(0, 'RunAs', 'notepad.exe', PChar(path + '\drivers\etc\hosts'), nil, SW_SHOWNORMAL);
end;
CoTaskMemFree(path);
end;
procedure TForm1.menuPWGenClick(Sender: TObject);
begin
PWGenForm.Show;
end;
procedure TForm1.menuReleaseRenewClick(Sender: TObject);
begin
ShellExecute(0, nil, 'cmd.exe', '/K "ipconfig /release & ipconfig /renew"', nil, SW_SHOWNORMAL);
end;
procedure TForm1.NetworkConnections1Click(Sender: TObject);
begin
ShellExecute(0, nil, 'ncpa.cpl', nil, nil, SW_SHOWNORMAL);
end;
procedure TForm1.Pinggraph1Click(Sender: TObject);
var
frm:TPingGraphForm;
begin
frm := TPingGraphForm.Create(Self);
frm.Show;
end;
procedure TForm1.Refresh1Click(Sender: TObject);
begin
tvInterfaces.Items.BeginUpdate;
tvInterfaces.Items.Clear;
FillTreeView;
tvInterfaces.Items.EndUpdate;
end;
procedure TForm1.ReloadConnectionProperties;
var
c, count:Cardinal;
IfBuffer:Array Of Byte;
Addresses:PIP_ADAPTER_ADDRESSES;
item:TMenuItem;
visible:Boolean;
const
flags =
GAA_FLAG_INCLUDE_GATEWAYS or
GAA_FLAG_SKIP_UNICAST or
GAA_FLAG_SKIP_ANYCAST or
GAA_FLAG_SKIP_MULTICAST
;
begin
// Clear old ConnectionProperties items
ConnectionProperties1.Clear;
visible := False;
count := 0;
c := GetAdaptersAddresses(AF_INET, flags, nil, @IfBuffer[0], @count);
if (c <> ERROR_BUFFER_OVERFLOW) then Exit;
SetLength(IfBuffer, count);
c := GetAdaptersAddresses(AF_INET, flags, nil, @IfBuffer[0], @count);
if (c <> ERROR_SUCCESS) then Exit;
Addresses := @IfBuffer[0];
while (Addresses <> nil) do begin
// Add only "interesting" interfaces to the menu
if (globalConfig.TestInterfaceRegex(Addresses.FriendlyName) = False) then begin
item := TMenuItem.Create(pmTrayIcon);
item.Caption := Addresses.FriendlyName;
item.OnClick := ConnectionPropertiesOnClick;
ConnectionProperties1.Add(item);
visible := True;
end;
Addresses := Addresses.Next;
end;
ConnectionProperties1.Visible := visible;
end;
procedure TForm1.ReloadTools;
var
item:TMenuItem;
icon:TIcon;
I:Integer;
begin
// Clear old tools items (tag property > 1)
for I:=SwissArmyKnife1.Count-1 downto 0 do begin
item := SwissArmyKnife1.Items[I];
if (item.Tag > 0) then SwissArmyKnife1.Remove(item);
end;
imgTrayMenuIcons.Clear;
// Add Items
item := TMenuItem.Create(pmTrayIcon);
item.Caption := '-';
item.Tag := 1;
SwissArmyKnife1.Add(item);
icon := TIcon.Create;
for I:=0 to globalconfig.InstalledTools.Count-1 do begin
item := TMenuItem.Create(pmTrayIcon);
item.Caption := globalconfig.InstalledTools[I].Name;
item.OnClick := ToolOnClick;
item.Tag := I+1;
icon.Handle := globalconfig.InstalledTools[I].Icon;
imgTrayMenuIcons.AddIcon(icon);
item.ImageIndex := imgTrayMenuIcons.Count - 1;
SwissArmyKnife1.Add(item);
end;
icon.Free;
end;
procedure TForm1.Settings1Click(Sender: TObject);
begin
ConfigForm.Show;
end;
procedure TForm1.ToolOnClick(Sender: TObject);
var
item:TMenuItem;
begin
item := Sender as TMenuItem;
ShellExecute(0, nil, PChar(globalConfig.InstalledTools[item.Tag-1].Path), nil, nil, SW_SHOWNORMAL);
end;
procedure TForm1.TrayIcon1Click(Sender: TObject);
begin
Show;
end;
procedure TForm1.TrayIcon1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
r:SmallInt;
begin
r := GetAsyncKeyState(VK_CONTROL);
if ((r and $8000) = $8000) then begin
PopupForm.ShowAgain;
end;
end;
procedure TForm1.WndProc(var msg:TMessage);
begin
if (msg.Msg = WM_SETTINGCHANGE) then begin
if (PChar(Pointer(msg.LParam)) = 'ImmersiveColorSet') then begin
CheckTrayIcon;
end;
end;
inherited WndProc(msg);
end;
end.