Delphi-Quellcode:
uses
ActiveX;
...
procedure GetAssociatedIconEx(
const Filename:
string; Icon: TIcon);
var
SHFileInfo: TSHFileInfo;
begin
FillChar(SHFileInfo, SizeOf(TSHFileInfo), 0);
if (SHGetFileInfo(PChar(Filename), FILE_ATTRIBUTE_NORMAL, SHFileInfo, SizeOf(TSHFileInfo), SHGFI_ICON
or SHGFI_USEFILEATTRIBUTES) <> 0)
then
try
Icon.Handle := CopyIcon(SHFileInfo.hIcon);
finally
DestroyIcon(SHFileInfo.hIcon);
end;
end;
procedure TExtMan_form.FlatButton2Click(Sender: TObject);
begin
GetAssociatedIconEx('
Test.ccd', Icon.Picture.Icon);
end;
...
initialization
CoInitialize(
nil);
finalization
CoUnInitialize;
end.
Versuche es mal mit
CoInitialize, dann geht es bei mir wenn man die
unit ActiveX mit einbindet.