Uses ShellAPI;
...
Button1 : TButton;
ImageList1 : TImageList;
TListView1 : TListView;
...
...
procedure TForm1.Button1Click(Sender: TObject);
var
IconIndex: word;
sFileName:String;
Buffer: array[0..2048] of char;
IconHandle: HIcon;
...
Button1 : TButton;
ImageList1 : TImageList;
TListView1 : TListView;
...
...
procedure TForm1.Button1Click(Sender: TObject);
var
IconIndex: word;
sFileName:String;
Buffer: array[0..2048] of char;
IconHandle: HIcon;
objIcon:TIcon;
i, iCount:Integer;
lvItem:TListItem;
begin
i, iCount:Integer;
lvItem:TListItem;
begin
objIcon := TIcon.Create;
sFileName := 'Shell32.dll';
StrCopy(@Buffer, PChar(sFileName));
iCount := ExtractIcon(HInstance, PChar(sFileName), $FFFFFFFF);
for i := 0 to iCount-1 do
begin
IconIndex := i;
IconHandle := ExtractAssociatedIcon(HInstance, Buffer, IconIndex);
if IconHandle <> 0 then
objIcon.Handle := IconHandle;
ImageList1.AddIcon(objIcon);
lvItem := ListView1.Items.Add;
lvItem.ImageIndex := i;
lvItem.Caption := IntToStr(i);
end;
end;
sFileName := 'Shell32.dll';
StrCopy(@Buffer, PChar(sFileName));
iCount := ExtractIcon(HInstance, PChar(sFileName), $FFFFFFFF);
for i := 0 to iCount-1 do
begin
IconIndex := i;
IconHandle := ExtractAssociatedIcon(HInstance, Buffer, IconIndex);
if IconHandle <> 0 then
objIcon.Handle := IconHandle;
ImageList1.AddIcon(objIcon);
lvItem := ListView1.Items.Add;
lvItem.ImageIndex := i;
lvItem.Caption := IntToStr(i);
end;
end;
Windows存放系統圖示的文件
shell32.dll:包含許多與 Windows Shell 有關的圖示imageres.dll: 是一個包含大量 Windows 系統圖示的檔案user32.dll:包含一些基本的系統圖示comctl32.dll:包含一些常用的圖示
參考:
CharGRT
Shell32.dll |
Imageres.dll |
User32.dll |
Comctl32.dll |
沒有留言:
張貼留言