Einzelnen Beitrag anzeigen

Nogge

Registriert seit: 15. Jul 2004
336 Beiträge
 
Delphi 7 Professional
 
#5

Re: FTP Client: Icons von den Dateien des Servers erhalten

  Alt 7. Apr 2006, 10:25
Delphi-Quellcode:
  AIcon := TIcon.Create;
  try
    AIcon.Handle := GetShellIcon(ExtractFileExt(DL_Item.Caption), SHGFI_USEFILEATTRIBUTES);
    Item.ImageIndex := IL_loc.AddIcon(AIcon);
  finally
    AIcon.Free;
  end;
// ------------------------------------------------------------------------------
function TForm1.GetShellIcon(const FileName: string; Flags: Cardinal = 0): HICON;
{
  dwFileAttr:
  FILE_ATTRIBUTE_READONLY            = $00000001;
  FILE_ATTRIBUTE_HIDDEN              = $00000002;
  FILE_ATTRIBUTE_SYSTEM              = $00000004;
  FILE_ATTRIBUTE_DIRECTORY            = $00000010;
  FILE_ATTRIBUTE_ARCHIVE              = $00000020;
  FILE_ATTRIBUTE_NORMAL              = $00000080;
  FILE_ATTRIBUTE_TEMPORARY            = $00000100;
  FILE_ATTRIBUTE_COMPRESSED          = $00000800;
  FILE_ATTRIBUTE_OFFLINE              = $00001000;

  Flags:
  SHGFI_LINKOVERLAY
  SHGFI_OPENICON
  SHGFI_USEFILEATTRIBUTES
}

var
  fInfo : TSHFileInfo;
  dwFileAttr : Cardinal;
begin
  FillMemory(@fInfo, SizeOf(fInfo), 0);

  if (FileName = '') then
    dwFileAttr := FILE_ATTRIBUTE_DIRECTORY
  else
    dwFileAttr := 0;

  SHGetFileInfo(PChar(FileName), dwFileAttr, fInfo, SizeOf(fInfo), Flags or SHGFI_ICON);

  Result := fInfo.hIcon;
end;
  Mit Zitat antworten Zitat