1
In Delphi 10.1.2 Berlin, muss ich entweder das große Symbol (32x32) oder das kleine Symbol (16x16) aus an.EXE Datei, unter Verwendung eines spezifischen IconIndex extrahieren:Get Klein oder Groß-Symbol Von Ausführbare Datei
function GetIconFromExecutableFile(const AFileName: string; const Large: Boolean; const AIconIndex: Integer): TIcon;
var
Icon: HICON;
ExtractedIconCount: UINT;
ThisIconIdx: Integer;
F: string;
begin
Result := nil;
try
ThisIconIdx := AIconIndex;
F := AFileName;
if Large then
begin
// error on nil: [dcc32 Error]: E2033 Types of actual and formal var parameters must be identical
ExtractedIconCount := ExtractIconEx(PChar(F), ThisIconIdx, Icon, nil, 1);
end
else
begin
// error on nil: [dcc32 Error]: E2033 Types of actual and formal var parameters must be identical
ExtractedIconCount := ExtractIconEx(PChar(F), ThisIconIdx, nil, Icon, 1);
end;
Win32Check(ExtractedIconCount = 1);
Result := TIcon.Create;
Result.Handle := Icon;
except
Result.Free;
raise;
end;
end;
Die Verwendung von nil
für die ausgeschlossene Symbolgröße erzeugt einen Compilerfehler.
Also wie bekomme ich das gewünschte Symbol?
https://stackoverflow.com/a/5955676/6426692 – Sami
, das gut funktioniert . – user1580348
Die Quelle (in WinAPI.ShellAPI.pas) zeigt die Deklaration als 'Funktion ExtractIconEx (lpszFile: LPCWSTR; nIconIndex: Ganzzahl; var phiconLarge, phiconSmall: HICON; nIcons: UINT): UINT; stdcall; ', und eindeutig' nil' kann nicht als 'var' Parameter übergeben werden. –