uses
ShellApi;
function GetAssociatedIcon(const AExtension: string; ASmall: Boolean): HIcon;
var
Info: TSHFileInfo;
Flags: Cardinal;
begin
if ASmall then
Flags := SHGFI_ICON or SHGFI_SMALLICON or SHGFI_USEFILEATTRIBUTES
else
Flags := SHGFI_ICON or SHGFI_LARGEICON or SHGFI_USEFILEATTRIBUTES;
SHGetFileInfo(PChar(AExtension), FILE_ATTRIBUTE_NORMAL, Info, SizeOf(TSHFileInfo), Flags);
Result := Info.hIcon;
end;
procedure TForm1.Button1.Click(Sender: TObject);
begin
Icon.Handle := GetAssociatedIcon('.html', True);
end;