如何在delphi中编写并提取exe文件里面的ICO图标
2个回答
2017-08-04 · 知道合伙人软件行家
关注
展开全部
提取 exe 文件里面的 ICO 图标,通常可以 WinAPI 函数 ExtractIcon,以下是示例代码:
procedure TForm1.RzBitBtn1Click(Sender: TObject);
var iCount: Integer;
begin
if OpenDialog1.Execute then
begin
Edit1.Text := OpenDialog1.FileName;
iCount := ExtractIcon(HInstance, PChar(OpenDialog1.FileName), $FFFFFFFF);
if iCount>0 then
begin
Label2.Caption := Format('当前 EXE 文件中共包含 %d 个 ICON 资源。',[iCount]);
Image1.Picture.Icon.Handle := ExtractIcon(HInstance,PChar(OpenDialog1.FileName),0);
end else
begin
Label2.Caption := '当前 EXE 文件中不包含 ICON 资源。';
end;
end;
end;
运行效果截图:
2017-11-16 · 知道合伙人互联网行家
关注
展开全部
会写自己的EXE程序,但没一个好看的EXE图标,是不是很遗憾啊?很多软件都有很好看的图标,我们为什么不提取出来呢?下面教你怎么用delphi编程提取EXE文件的图标,并保存为ICO格式的.
代码如下:
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<count)then
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;
代码如下:
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<count)then
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;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询