zoukankan      html  css  js  c++  java
  • Delphi提取EXE,DLL文件图标

    //uses ShellAPI

    procedure   TForm1.Button1Click(Sender:   TObject);
    var
          IconIndex:Word;
          h:hICON;
    begin
          IconIndex:=0;
          h:=ExtractIcon(HInstance,pchar('c:"windows"notepad.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;

  • 相关阅读:
    SQL优化,解决系统运行效率瓶颈
    C#中 哪些是值类型 哪些是引用类型
    C#异常类相关总结
    对象 序列化 字节流 传输
    给数组中的每个元素赋值
    对象转化为 xml字符串
    .NET BETWEEN方法
    Datatable To List<Entity>
    ajax原理
    gulp记录
  • 原文地址:https://www.cnblogs.com/lzhdim/p/1343857.html
Copyright © 2011-2022 走看看