![]() |
Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
Moin
Ich hab folgenden Code
Delphi-Quellcode:
Problem ist nur: szDisplayName beinhaltet nicht wider Erwarten nach der MSDN den Namen der Datei, wo das Icon abgespeichert is, sondern ist einfach nur leer. Ich habe erst gedacht ich hätte bei der weiteren Weiterverarbeitung nen Fehler beim Typecast gemacht, doch nachhem gesetzten Haltepunkt zeigt Delphi mir auch an das fi.szDisplayName komplett leer ist.
var
fi: SHFileInfo; begin AFile := 'C:\irgendeine.bmp'; SHGetFileInfo(pChar(AFile), 0, fi, SizeOf(fi), SHGFI_ICONLOCATION) // 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. end; Woran kann sowas liegen ? Bin ich zu blöd nu drei bzw. vier Parameter zu übergeben oder liegt das anner WinAPI ? MfG - Thebe |
Re: Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
*schiiiieeeb*
Keiner ne Ahnung woran das liegen könnte ?? |
Re: Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
Was hast du denn für eine Datei angegeben?
|
Re: Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
Zitat:
Delphi-Quellcode:
Wenn Du im Member DisplayName was drinstehen haben möchtest, dann musst Du das der Funktion auch in den Flags (SHGFI_DISPLAYNAME) mitteilen. Das DestroyIcon sollte man auch nicht vergessen, wenn man im Rahmen von Spielereien mal SHGFI_ICON verwendet...
SHGetFileInfo(pChar(AFile), 0, fi, SizeOf(fi), SHGFI_ICONLOCATION or SHGFI_TYPENAME or SHGFI_DISPLAYNAME);
ShowMessage('Displayname: '+strpas(fi.szDisplayName)+#13+ 'Typename: '+strpas(fi.szTypeName)+#13+ 'IIcon: '+IntToStr(fi.IIcon)); if fi.hIcon > 0 then DestroyIcon(fi.hIcon); |
Re: Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
@Luckie: PDF, BMP u. XLS Dateien von meiner Festplatte, Pfad war korrekt und die Dateien waren existent.
@Union: Zitat:
Ma ne Beschreibung von SHGFI_DISPLAYNAME vonna MSDN Seite: Zitat:
Aber danke für die Antwort :) |
AW: Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
Ich hab 1:1 dasselbe Problem. Gibt es inzwischen eine Lösung?
|
AW: Problem mit SHGetFileInfo und SHGFI_ICONLOCATION
Ich hab hier was. Ich brauch das Icon der Datei. Vielleicht hilfts.
Delphi-Quellcode:
function GetGenericIconIndex( AExtension: string ): integer;
{ Get icon index for an extension type } var AInfo: TSHFileInfo; begin if SHGetFileInfo( PChar( AExtension ), FILE_ATTRIBUTE_NORMAL, AInfo, SizeOf( AInfo ), SHGFI_SYSICONINDEX or SHGFI_LARGEICON or SHGFI_USEFILEATTRIBUTES ) <> 0 then Result := AInfo.iIcon else Result := -1; end; procedure BuildImageList; var FileInfo: TSHFileInfo; dw:DWORD; begin Inherited Create(AOwner); fImageList:= TImageList.Create(self); dw:=SHGetFileInfo('', 0, FileInfo, SizeOf(TSHFileInfo), SHGFI_LARGEICON or SHGFI_SYSICONINDEX ); if dw>0 then begin fImageList.Width:= 32; fImageList.Height:=32; fImageList.ShareImages:= True; fImageList.Handle:= dw; List.LargeImages:= fImageList;// is a TListView ! end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:22 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz