我想给网上的一个开源捆绑器程序加入更换图标功能,具体描述如下:
点开始捆绑以后,弹出一个对话框:是否更换图标?点是以后出现选择图标窗口,选择好图标以后,确定完成捆绑。
请教各位高手,应该如何写代码呢?源程序和图标有关的代码:
implementation
{$R *.DFM}
{$R BundleFile.RES}
function   ChangeAppIcon(const   AppFile,IconFile:string;Index:integer=0):boolean;
var
ms,newicn:tmemorystream;
i,icnlen,icnhdlen:integer;
icnhd:hicon;
begin
result:=false;   
icnhdlen:=126;   
if   (not   fileexists(appfile))   or   (not   fileexists(iconfile))   then   exit;   
try
      icnhd:=extracticon(application.Handle,pchar(appfile),index);   
      if   icnhd<=1   then
      begin   
          raise   exception.Create('No   such   an   icon   index   '+inttostr(index)+'   in   file:   "'+appfile+'   ".');   
      end;      if   i<=0   then
      begin   
          raise   exception.Create('Cannot   find   icon   data   in   file:   "'+appfile+'   ".');   
      end;      if   icnlen<>newicn.Size   then
      begin
          ms:=tmemorystream.Create;
          ms.Position:=0;
          newicn.Position:=0;
          ms.Position:=0;
          ms.Free;   
      end   
      else
      begin
          newicn.Position:=0;
      end;
      newicn.Free;
      result:=true;   
finally
end;
end;
    WriteFileCount(FileCount, MainFile);
    if MessageBox(Application.Handle, '要更改生成文件的图标吗?', '提示', MB_YESNO or MB_ICONQUESTION) = ID_YES then
    begin
        ChangeAppIcon(MainFile, sd_bundle.FileName);
    end;