会写自己的EXE程序,但没一个好看的EXE图标,是不是很遗憾啊?很多软件都有很好看的图标,我们为什么不提取出来呢?下面教你怎么用delphi编程提取EXE文件的图标,并保存为ico格式的.
代码如下:
word-WRAP: break-word" bgColor=#f3f3f3>
procedureTForm1.getIcon; var Count:Integer; FileName:String; i:integer; begin if(FileName<>Edit1.Text)then begin FileName:=Edit1.Text; I:=0; Count:=ExtractIcon(Application.Handle,PChar(FileName), $FFFFFFFF); end else Inc(I); if(I Image1.Picture.Icon.Handle:= ExtractIcon(Application.Handle,PChar(FileName),I) else ShowMessage(’没有找到!’); end; procedureTForm1.Button1Click(Sender:TObject); begin getIcon; end; procedureTForm1.Button2Click(Sender:TObject); begin opendialog1.Execute; edit1.Text:=opendialog1.FileName; end; procedureTForm1.Button3Click(Sender:TObject); begin savedialog1.Execute; image1.Picture.SaveToFile(savedialog1.FileName); end; |
界面: