Einzelnen Beitrag anzeigen

Benutzerbild von Jonas Shinaniganz
Jonas Shinaniganz

Registriert seit: 30. Aug 2011
249 Beiträge
 
Delphi XE5 Ultimate
 
#2

AW: Firemonkey TIcon

  Alt 11. Mär 2012, 01:17
Mein eigentliches Problem ist, dass Ich folgenden Code nicht ausführen kann weil TIcon nicht verfügbar ist und Ich nicht weiß wie Ich nun vorgehen soll.
Mein Etappen-Ziel ist es das Icon einer Datei auszulesen. Das ganze soll nicht nur bei Exe Dateien klappen sondern auch bei Files das entsprechende Icon ausgeben.

Delphi-Quellcode:
var
  MyIcon:TIcon;
  icoHandle: HIcon;
begin
  MyIcon:=TIcon.Create;
  try
   icoHandle := ExtractIcon(application.handle,'c:\windows\explorer.exe', 0) ;
   MyIcon.Handle:=icoHandle;
   Image1.Picture.Icon:=MyIcon;
  finally
   MyIcon.free;
  end;
end;
Das hier liefert mir bei Exe Files ein Handle zurück (Jedenfalls nicht 0):

Delphi-Quellcode:
procedure TBarButton.GetIcon;
var
  icoHandle : HIcon;
begin
  icoHandle := ExtractIcon(HInstance, PChar(FShortCut), 0);
end;
In der Hilfe habe ich noch etwas vielversprechenderes gelesen:
Zitat:
SHGFI_ICONLOCATION
Retrieve the name of the file that contains the icon representing the file specified by pszPath, as returned by the IExtractIcon::GetIconLocation method of the file's icon handler. Also retrieve the icon index within that file. The name of the file containing the icon is copied to the szDisplayName member of the structure specified by psfi. The icon's index is copied to that structure's iIcon member.
Das ist Teil von der SHGetFileInfo Function.

Jetzt weiß Ich leider nicht so wirklich weiter... hat jemand einen Ansatz?
  Mit Zitat antworten Zitat