这还不简单,不需要放在Res中,放在exe的文件尾部,<br>要运行是取出来,用winexec执行就可以,下面的两个函数是关键:<br><br>//将一个exe文件加到原文件的后面;<br>Function Cjt_AddtoFile(SourceFile,TargetFile:string): Boolean;<br>var<br> Target, Source: TFileStream;<br> MyFileSize: integer;<br>begin<br> try<br> Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareDenyWrite);<br> Target:=TFileStream.Create(TargetFile,fmOpenWrite or fmShareExclusive);<br> try<br> Target.Seek(0,soFromEnd);//&Iacute;ù&Icirc;&sup2;&sup2;&iquest;&Igrave;í&frac14;&Oacute;×&Ecirc;&Ocirc;&acute;<br> Target.CopyFrom(Source,0);<br> //&frac14;&AElig;&Euml;&atilde;×&Ecirc;&Ocirc;&acute;&acute;ó&ETH;&iexcl;&pound;&not;&sup2;&cent;&ETH;&acute;&Egrave;&euml;&cedil;¨&sup3;&Igrave;&Icirc;&sup2;&sup2;&iquest;;<br> MyFileSize:=Source.Size+4;//Sizeof(MyFileSize);<br> Target.WriteBuffer(MyFileSize,4);//sizeof(MyFileSize));<br> finally<br> Target.Free;<br> Source.Free;<br> end;<br> except<br> Result:=False;<br> Exit;<br> end;<br> Result:=True;<br>end;<br><br>//先前放在exe原文件 的Exe文件取出来<br>Function Cjt_DetachFromFile(SourceFile, TargetFile :string): Boolean;<br>var<br> Source: TFileStream;<br> Target: TMemoryStream;<br> MyFileSize: integer;<br>begin<br> try<br> Target:=TMemoryStream.Create;<br> Source:=TFileStream.Create(SourceFile, fmOpenRead or fmShareDenyWrite);<br> try<br> Source.Seek(-sizeof(MyFileSize),soFromEnd);<br> Source.ReadBuffer(MyFileSize, sizeof(MyFileSize));//&para;&Aacute;&sup3;&ouml;×&Ecirc;&Ocirc;&acute;&acute;ó&ETH;&iexcl;<br> Source.Seek(-MyFileSize,soFromEnd);//&para;¨&Icirc;&raquo;&micro;&frac12;×&Ecirc;&Ocirc;&acute;&Icirc;&raquo;&Ouml;&Atilde;<br> Target.CopyFrom(Source,MyFileSize-sizeof(MyFileSize));//&Egrave;&iexcl;&sup3;&ouml;×&Ecirc;&Ocirc;&acute;<br> Target.SaveToFile(TargetFile);//&acute;&aelig;·&Aring;&micro;&frac12;&Icirc;&Auml;&frac14;&thorn;<br> finally<br> Target.Free;<br> Source.Free;<br> end;<br> except<br> Result:=false;<br> Exit;<br> end;<br> Result:=true;<br>end;<br>