-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
frmIcons.pas
141 lines (128 loc) · 3.84 KB
/
frmIcons.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
unit frmIcons;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, UCL.TUText,
UCL.TUButton, Vcl.ExtCtrls, UCL.TUScrollBox, IniFiles, Vcl.ExtDlgs;
type
TframeIcons = class(TFrame)
UScrollBox2: TUScrollBox;
ListBox1: TListBox;
imgOriginal: TImage;
UButton5: TUButton;
UText3: TUText;
OpenPictureDialog1: TOpenPictureDialog;
imgNormal: TImage;
imgAlt: TImage;
UText1: TUText;
UText2: TUText;
UText4: TUText;
UButton1: TUButton;
UButton2: TUButton;
UButton3: TUButton;
procedure UButton5Click(Sender: TObject);
procedure UButton1Click(Sender: TObject);
procedure UButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function ListLnkFiles: Integer;
end;
implementation
{$R *.dfm}
uses main, taskbar, shlobj;
function TframeIcons.ListLnkFiles: Integer;
var
PinnedPath: String;
SRec: TSearchRec;
Res: Integer;
I, Index: Integer;
//BannedLnks: THashedStringList;
Ini: TIniFile;
begin
Result := 0;
PinnedPath := GetEnvironmentVariable('APPDATA') + '\Microsoft\Internet Explorer\Quick Launch\User Pinned\Taskbar\';
if DirectoryExists(PinnedPath) then
begin
ListBox1.Items.BeginUpdate;
ListBox1.Items.Clear;
(*if FileExists(PinnedPath + 'desktop.ini') then
begin
BannedLnks := THashedStringList.Create;
BannedLnks.Sorted := True;
BannedLnks.Duplicates := dupIgnore;
BannedLnks.Sort;
try
ini := TIniFile.Create(PinnedPath + 'desktop.ini');
try
ini.ReadSection('LocalizedFileNames', BannedLnks);
finally
ini.Free;
end;
finally
// bannedlnks kept on memory until we read all
end;
end;*)
Res := FindFirst(PinnedPath + '*.lnk', faAnyFile, SRec);
if Res = 0 then
try
while Res = 0 do
begin
if (SRec.Attr and faDirectory <> faDirectory) then
begin
(*if BannedLnks <> nil then
begin
if BannedLnks.Find(SRec.Name, Index) then
begin
// let's ignore this lnk
end
else
begin
ListBox1.Items.Add(StringReplace(SRec.Name, '.lnk', '', [rfReplaceAll]));
Inc(Result);
end;
end
else *)
begin
ListBox1.Items.Add(SRec.Name);
Inc(Result);
end;
end;
Res := FindNext(SRec);
end;
finally
FindClose(SRec);
end;
// if banned was found
//FreeAndNil(BannedLnks);
ListBox1.Items.EndUpdate;
end;
end;
procedure TframeIcons.UButton1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
begin
imgNormal.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;
end;
procedure TframeIcons.UButton2Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
imgAlt.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;
procedure TframeIcons.UButton5Click(Sender: TObject);
begin
// Update taskbar icons
SHChangeNotify($8000000, $1000, nil, nil);
ShowWindow(Form1.Taskbar.Handle, SW_HIDE);
Sleep(500);
ShowWindow(Form1.Taskbar.Handle, SW_SHOW);
UpdateWindow(Form1.Taskbar.Handle);
RedrawWindow(Form1.Taskbar.Handle, 0, 0, RDW_FRAME or RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN);
//RedrawWindow(Taskbar.Handle, @Taskbar.Rect, 0, RDW_FRAME or RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN);
InvalidateRect(Form1.Taskbar.Handle, @Form1.Taskbar.Rect, False);
//SystemParametersInfo(SPI_SETWORKAREA, 0, nil, SPIF_SENDCHANGE);
Form1.ForceForeground(Form1.Taskbar.Handle);
end;
end.