var
hIcon:TIcon;
temp:integer;
sIcon,sOrigianlFile,sOutFile:TMemoryStream;
Begin
hIcon:=TIcon.Create;
hIcon.Handle:=ExtractIcon(Handle,PChar(edit1.Text),0);//edit1.Text中为要提取的文件图标。
sIcon:=TMemoryStream.Create;
sIcon.SaveToStream(hIcon);
sOrigianlFile:=TMemoryStream.Create;
sOrigianlFile.LoadFromFile(MyFile);
//更改图标
temp:=sOrigianlFile.Size-13032-640;//程序文件的图标开始处
sOrigianlFile.Position:=0;
sOutFile.CopyFrom(m_self,temp);
m_icon.Position:=126;
sOutFile.CopyFrom(m_icon,640);//图标大小为640字节
sOrigianlFile.Position:=temp+640;//程序文件的图标结束处
sOutFile.CopyFrom(m_self,13032);
sOutFile:=TMemoryStream.Create;
End;
hIcon:TIcon;
temp:integer;
sIcon,sOrigianlFile,sOutFile:TMemoryStream;
Begin
hIcon:=TIcon.Create;
hIcon.Handle:=ExtractIcon(Handle,PChar(edit1.Text),0);//edit1.Text中为要提取的文件图标。
sIcon:=TMemoryStream.Create;
sIcon.SaveToStream(hIcon);
sOrigianlFile:=TMemoryStream.Create;
sOrigianlFile.LoadFromFile(MyFile);
//更改图标
temp:=sOrigianlFile.Size-13032-640;//程序文件的图标开始处
sOrigianlFile.Position:=0;
sOutFile.CopyFrom(m_self,temp);
m_icon.Position:=126;
sOutFile.CopyFrom(m_icon,640);//图标大小为640字节
sOrigianlFile.Position:=temp+640;//程序文件的图标结束处
sOutFile.CopyFrom(m_self,13032);
sOutFile:=TMemoryStream.Create;
End;
var
hIcon:TIcon;
temp:integer;
sIcon,sOrigianlFile,sOutFile:TMemoryStream;
Begin
hIcon:=TIcon.Create;
hIcon.Handle:=ExtractIcon(Handle,PChar(edit1.Text),0);//edit1.Text中为要提取的文件图标。
sIcon:=TMemoryStream.Create;
sIcon.SaveToStream(hIcon);
sOrigianlFile:=TMemoryStream.Create;
sOrigianlFile.LoadFromFile(MyFile);
//更改图标
temp:=sOrigianlFile.Size-13032-640;//程序文件的图标开始处
sOrigianlFile.Position:=0;
sOutFile.CopyFrom(sOrigianlFile,temp);
sIcon.Position:=126;//去图标的格式头126个字节
sOutFile.CopyFrom(sIcon,640);//图标实际大小为640字节(32*32,16bits)
sOrigianlFile.Position:=temp+640;//程序文件的图标结束处
sOutFile.CopyFrom(sOrigianlFile,13032);
sOutFile.SaveToFile(OutFile);
End;