家里的机器没Delphi
看看winexec的函数

解决方案 »

  1.   

    理论上说是用 application.terminate.
    但实际上它并没有处理好,程序中要如何控制得干净我也想知道。
      

  2.   

    Application.Terminate;
    Exit;
    你可以试一试;
    或者:
    Application.Halt//不推荐你用;
      

  3.   

    Application.Halt//您不认为它干净了吗?
    嘻嘻,什么都不作处理了;
    Kill
      

  4.   

    appliction.terminate
    或者ctrl+F2  Alt+F4
      

  5.   

    The TerminateProcess function terminates the specified process and all of its threads. BOOL TerminateProcess(    HANDLE hProcess, // handle to the process 
        UINT uExitCode  // exit code for the process  
       );
     ParametershProcessIdentifies the process to terminate. 
    Windows NT: The handle must have PROCESS_TERMINATE access. For more information, see Process Objects. uExitCodeSpecifies the exit code for the process and for all threads terminated as a result of this call. Use the GetExitCodeProcess
     function to retrieve the process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value.  Return ValuesIf the function succeeds, the return value is nonzero.
    If the function fails, the return value is zero. To get extended error information, call GetLastError. ResThe TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess. 
    TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. Terminating a process causes the following: 1.All of the object handles opened by the process are closed. 
    2.All of the threads in the process terminate their execution. 
    3.The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate. 
      

  6.   

    delphi5中没有application.halt啊??
      

  7.   

    uses tlhelp32;
    假设要终止的程序的文件名为:project2.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))='PROJECT2.EXE' then
      begin
        hh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);
        TerminateProcess(hh,0);
      end;
      found:=process32next(sshandle,lppe);
    end;
    end;
    ********************
    HANDLE hProcess
    Windows NT/2000: The handle must have PROCESS_TERMINATE access. 
    For more information, see Process Security and Access Rights. 所以要先使用 
    DWORD SetSecurityInfo(
      HANDLE handle,                     // handle to object
      SE_OBJECT_TYPE ObjectType,         // object type
      SECURITY_INFORMATION SecurityInfo, // buffer
      PSID psidOwner,                    // new owner SID
      PSID psidGroup,                    // new primary group SID
      PACL pDacl,                        // new DACL
      PACL pSacl                         // new SACL
    );
      

  8.   

    就是application.terminate就行了。
      

  9.   

    谢谢大各位了,不过我最后还是用API解决的
      

  10.   

    哦,虽然不能帮你,但是帮你UP一下!
    UP!
      

  11.   

    Application.Halt;
    用他来强行关闭就已经可以了.