Extracting both the small and the large icon from a file (Views: 17)
Extracting both the small and the large icon from a file
The Windows help files only document ExtractIcon which extracts the large icon from an EXE (DLL, etc.).
There is an undocumented function ExtractIconEx which retrieves both the small and the large icon as shown below.
procedure TForm1.FormPaint(Sender: TObject);
// draw a stripe with all large icons contained in the file
// and below of that a stripe with all small icons.
FileName := 'C:\WinNT\RegEdit.exe';
IconCount := ExtractIconEx(FileName, -1, LargeIcon, SmallIcon, 0);
for i := 0 to Pred(IconCount) do
ExtractIconEx(FileName, i, LargeIcon, SmallIcon, 1);
DrawIcon(Canvas.Handle, 5 + i * 36, 5, LargeIcon);
DrawIconEx(Canvas.Handle, 5 + i * 36, 50, SmallIcon,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
<< Back to main page