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;

  • 相关阅读:
    Codeforces Round #239(Div. 2) 做后扯淡玩
    hdu 3507 Print Article
    prufer序列
    POJ 2778 DNA Sequence
    Codeforces Round #237 (Div. 2)
    poj3352
    图论知识
    POJ 2186
    Codeforces Round #236 (Div. 2)
    POJ 2823 Sliding Window
  • 原文地址:https://www.cnblogs.com/lzhdim/p/1343857.html
Copyright © 2011-2022 走看看