uses ShlObj;
function GetFileIcon(const AFileName:String; const ASmallIcon:Boolean): HICON;
var
Flag: Integer;
info: TShFileInfo;
begin
if ASmallIcon then
Flag:=(SHGFI_SMALLICON or SHGFI_ICON)
else
Flag:=(SHGFI_LARGEICON or SHGFI_ICON);
SHGetFileInfo(Pchar(AFileName),0,info,Sizeof(info),Flag);
Result:=info.hIcon;
end;