Einzelnen Beitrag anzeigen

Benutzerbild von FriFra
FriFra

Registriert seit: 19. Apr 2003
1.291 Beiträge
 
Delphi 2005 Professional
 
#29
  Alt 20. Jun 2003, 22:41
Zitat von Marco Haffner:
Hast Du eigentlich meine Routine auch ausprobiert...
Hab ich...


Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, ExtCtrls, ShellAPI;

type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure GetAssociatedIconEx(const Filename : String; Icon : TIcon);
var
  SHFileInfo: TSHFileInfo;
begin
  // CoInitialize has to be called before SHGetFileInfo (done by Delphi)
  FillChar(SHFileInfo, SizeOf(TSHFileInfo), 0);
  if (SHGetFileInfo(PChar(Filename), FILE_ATTRIBUTE_NORMAL, SHFileInfo,
    SizeOf(TSHFileInfo), SHGFI_USEFILEATTRIBUTES or SHGFI_ICON or SHGFI_SMALLICON) <> 0) then
    // or SHGFI_LARGEICON, SHGFI_LINKOVERLAY, SHGFI_OPENICON, SHGFI_SELECTED
  try
    // get it
    Icon.Handle := CopyIcon(SHFileInfo.hIcon);
  finally
    // you are responsible for destroying the icon handle
    DestroyIcon(SHFileInfo.hIcon);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
GetAssociatedIconEx('c:\test.htm',Image1.Picture.Icon);
end;

end.
Miniaturansicht angehängter Grafiken
projekt1.jpg  
  Mit Zitat antworten Zitat