如何获得应用程序的图标呢????添加到imagelist呢??
Extracticon么?具体给点代码吧!!!

解决方案 »

  1.   

    uses
      ShellAPI;procedure TForm1.Button1Click(Sender: TObject);
    var
      icLarge, icSmall: TIcon;
      hLarge, hSmall: HICON;
    begin
      icLarge := TIcon.Create();
      icSmall := TIcon.Create();
      ExtractIconEx('C:\Program Files\Borland\Delphi7\Bin\Delphi32.exe',
                    0,
                    hLarge,
                    hSmall,
                    1);
      icLarge.Handle := hLarge;
      icSmall.Handle := hSmall;
      ImageList1.AddIcon(icLarge);
      ImageList1.AddIcon(icSmall);end;
      

  2.   

    有两个函数可以用:
    var
      FileInfo:_SHFILEINFO;
      sName:string;
      FileIcon:TIcon;
      Num:Integer;
    1.SHGetFileInfo.
    begin
      try
        FileIcon:=TIcon.Create;
        SHGetFileInfo(pchar(sName),0,FileInfo,sizeof(FileInfo),SHGFI_ICON);
        FileIcon.handle:=FileInfo.HIcon;
        ImageList1.addicon(FileIcon);//该函数的返回值为Icon在ImageList1中的Index.
      finally
        FileIcon.Free;
      end;
    end;
    2.ExtractIcon
    begin
      try
        FileIcon:=TIcon.Create;
        Num:=ExtractIcon(hInstance,pchar(sName),LongWord(-1));//取得文件中的Icon的数目
        if Num>0 then 
        begin
          FileIcon.HIcon:=ExtractIcon(hInstance,pchar(sName),LongWord(0));
          ImageList1.addicon(FileIcon);
        end;
      Finally
        FileIcon.Free;
      end;
    end;
    这两个函数的具体用法你可以查阅Delphi的帮助文档,也可以查阅介绍Api的一些资料