怎么更改EXE的主图标

怎样更改EXE的主图标?
怎样更改EXE的主图标?
不是在Delphi 更改当前程序的图标,
而是去改别的EXE文件的图标,
像 "熊猫烧香" 一样的效果,
又如灰鸽子的服务端生成器那样,能把生成的服务端的图标改为自己想要的图标.

也许思路是:

  PE文件的主图标是从26d2H处开始存放,你先载入一个图标到一个内存流中   
  再将要更改图标的EXE文件载入到另一个流中,将EXE文件流的指针指向   
  $26d2f,将图标流的指针指向$15,然后循环读取图标流到结尾并写入EXE文件流   
  就这样,EXE文件的图标已换成你自己的了。

这是网上找到的,但不懂应用,请懂的朋友给一下示范代码!谢谢!
------解决方案--------------------
procedure TForm1.Button1Click(Sender:TObject);
const
readlen = 10; //每次读取字节数,可改变
icolen = 766; //32*32图标长度,根据研究前126为图标头,后640为图标数据
var
i, j, itemp, nPos:int64; //   nPos为目的图标在目的文件的位置
ci, cj:array[0..readlen - 1] of char;
SourceFile, DestFile:string; //如果要把记事本图标换成瑞星杀毒软件图标
bOK:boolean; //则SourceFile='C:\windows\notepad.exe',DestFile:='C:\Progra
m Files\rising\rav\ravmon.exe'
   SourceIcon, DestIcon:TIcon;
SIconStream, s, sDest:TMemoryStream;
begin
bOK := false;
if OpenDialog1.Execute then
   SourceFile := OpenDialog1.FileName
else
   exit;
if AnsiUpperCase(ExtractFileExt(SourceFile)) <> '.EXE' then
begin
   ShowMessage(AnsiUpperCase(ExtractFileExt(SourceFile)));
   exit;
end;
Edit1.Text := SourceFile;
if OpenDialog2.Execute then
   DestFile := OpenDialog2.FileName
else
   exit;
if AnsiUpperCase(ExtractFileExt(DestFile)) <> '.EXE' then
   exit;
Edit2.Text := DestFile;
SourceIcon := TIcon.Create;
case ExtractIcon(handle, PChar(SourceFile), UINT(-1)) of
   0:
     begin ShowMessage('源程序没有图标');
       exit;
     end;
   1:;
else
   ShowMessage('源程序有多个图标,本程序选择第一个图标');
end;
SourceIcon.Handle := ExtractIcon(handle, PChar(SourceFile), 0);
   //选择第一个图

   DestIcon := TIcon.Create;
     //选择第N个图标为   ExtractIcon(handle,PChar(Source
file), N - 1)
case ExtractIcon(handle, PChar(DestFile), UINT(-1)) of
0:
   begin ShowMessage('目的程序没有图标');
     exit;
   end;
1:;
else
ShowMessage('目的程序有多个图标,本程序选择第一个图标替换');
end;
DestIcon.Handle := ExtractIcon(handle, PChar(DestFile), 0); //选择第一个图标
SIconStream := TMemoryStream.Create;
DestIcon.SaveToStream(sIconStream);
if sIconStream.size <> icolen then
ShowMessage('SIcon.size<>icolen');
SDest := TMemoryStream.Create;
sDest.LoadFromFile(DestFile);
i := 0;
j := 0; //以下程序查找目的图标在目的程序中的位置
while i < sDest.size do
begin
itemp := i;
j := 126;
{                               repeat
                                         SDest.Position:=i;
                                         sDest.read(ci,Readlen);
                                         SiconStream.Position:=j;
                                         SIconStream.Read(cj,Readlen);
                                         i:=i+Readlen;
                                         j:=j+Readlen;
                               until   (String(ci)=String(cj))   and   (i<sDest.size)   and   (j<icolen);
} ci := '';
cj := '';
while (string(ci) = string(cj)) and (i < SDest.size) and (j <
   icolen) do
begin
   i := i + readlen;
   j := j + readlen;