我的程序用了ole服务器,我想用过之后把它清除,但是不知道用什么函数.

解决方案 »

  1.   

    强制结束
    BOOL TerminateThread(    HANDLE hThread, // handle to the thread 
        DWORD dwExitCode  // exit code for the thread 
       );
      

  2.   

    看看http://expert.csdn.net/Expert/topic/1705/1705381.xml?temp=.6148188
      

  3.   

    其中参数exefilename是要杀掉的进程名function KillTask(ExeFileName: string): integer;
    const
      PROCESS_TERMINATE=$0001;
      //进程的PROCESS_TERMINATE访问权限
    var
      ContinueLoop: BOOL;
      FSnapshotHandle: THandle;
      FProcessEntry32: TProcessEntry32;
    begin
      result:= 0;
      FSnapshotHandle := CreateToolhelp32Snapshot
                         (TH32CS_SNAPPROCESS, 0);
     //获取系统所有进程快照
      FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
      //调用Process32First前用Sizeof(FProcessEntry32)填充FProcessEntry32.dwSize
      ContinueLoop := Process32First(FSnapshotHandle,
                                     FProcessEntry32);
     //获取快照中第一个进程信息并保存到FProcessEntry32结构体中
      while integer(ContinueLoop) <> 0 do
     //循环枚举快照中所有进程信息
      begin
        if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))
    =UpperCase(ExeFileName))
          or (UpperCase(FProcessEntry32.szExeFile)
    =UpperCase(ExeFileName))) then
    //找到要中止的进程名
           Result := Integer(TerminateProcess(OpenProcess(
                     PROCESS_TERMINATE, BOOL(0),
                     FProcessEntry32.th32ProcessID), 0));
         //中止进程
           ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
         //查找下一个符合条件进程
      end;
    end;
      

  4.   

    TerminateProcess
    TerminateThread
    不安全,应该用
    ExitProcess
    ExitThread
      

  5.   

    terminateprocess可以中斷進程!