例如已知c:\p1.exe这个程序正在运行,如何关闭或强制关闭它?

解决方案 »

  1.   

    var
       wnd:HWND;
    begin
    wnd:=Findwindow('p1.exe',nil);
       if wnd>0 then
          sendMessage(wnd,WM_CLOSE,0,0);//发送关闭消息
      

  2.   

    sendMessage(wnd,WM_CLOSE,0,0);//发送关闭消息
    不能关闭该程序吗?
      

  3.   

    有些程序的close???事件中的canclose是为False的。这样可以关闭吗?
      

  4.   

    给wwwwwa
      刚测试了一下 ,不能关闭。
      

  5.   

    Wnd的返回值总是0,但是程序确实在运行
      

  6.   

    uses  tlhelp32;  
    假设要终止的程序的文件名为:p1.exe,那么例程如下:  
    var  
    lppe:tprocessentry32;  
    sshandle:thandle;  
    hh:hwnd;  
    found:boolean;  
    begin  
    sshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);  
    found:=process32first(sshandle,lppe);  
    while  found  do  
    begin  
       //进行处理,其中lppe.szExefile就是程序名。  
       if  uppercase(extractfilename(lppe.szExeFile))='P1.EXE'  then  
       begin  
           hh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);  
           TerminateProcess(hh,0);  
       end;  
       found:=process32next(sshandle,lppe);  
    end;  
    end;  
      

  7.   

    谢谢!我试试。但相信Night。
    尽快结贴吧。