• Delphi提取EXE,DLL文件图标


    //uses ShellAPI
    procedure TForm1.Button1Click(Sender: TObject);
    var
    IconIndex:Word;
    h:hICON;
    begin
    IconIndex:=0;
    h:=ExtractIcon(HInstance,pchar('c:windows otepad.exe'),IconIndex);
    DrawICon(Form1.canvas.Handle,200,100,h);
    end;
    //用控件ImageList保存提取的图标,并在ListView中显示出来
    FIcon.Handle:=hIcon1;
    ImageList1.AddIcon(fIcon);
    ListItem:=ListView1.Items.Add;
    ListItem.ImageIndex:=ImageList1.Count-1;
    end;
    ====================================================
    use shellapi; //提取出图标并赋给SpeedButton.Glyph

    procedure TForm1.Button1Click(Sender: TObject);
    var
    hc: TIcon;
    Bitmap : TBitmap;
    begin
    //打开exe
    opendialog1.Execute;
    hc := TIcon.Create;
    Bitmap := TBitmap.Create;
    //提取exe图标
    hc.Handle := ExtractIcon(hInstance, PChar(opendialog1.FileName), 0);
    //将得到的ico转换为bitmap
    Bitmap.Width := hc.Width;
    Bitmap.Height := hc.Height;
    Bitmap.Canvas.Draw(0, 0, hc );
    //把bitmap传给speedbutton.glyph
    SpeedButton1.Glyph:=bitmap;
    //释放资源
    hc.Free;
    Bitmap.Free;
    end;

  • 相关阅读:
    【洛谷P2660烤鸡】
    cogs448
    排队打水
    洛谷U36590搬书
    NOIP2012借教室
    归并排序模版
    NOIP2015神奇的幻方
    NOIP2006能量项链
    NOIP2003加分二叉树
    NOI1995石子合并&多种石子合并
  • 原文地址:https://www.cnblogs.com/blogpro/p/11446773.html
Copyright © 2020-2023  润新知