知道进程id号,怎样关闭进程,用api函数
知道进程id号,用api函数能得到进程的地址吗?

解决方案 »

  1.   

    用TerminateProcess可以强行关闭进程,但是有时候你的进程运行级别不够需要调整运行级别才可以关闭一些级别比自己高的进程,这属于另一个话题了请参阅AdjustTokenPrivileges及相关函数
      

  2.   

    是这样的:我开了两个exe程序,进程id号不同,可用getcurrentprocess得到的地址是一样的
    我想在一个某个exe中关掉这两个exe程序,怎么做?
      

  3.   

    getcurrentprocess返回本程序的伪据柄,在不同程序内是相同的(也有例外),如果你想调用TerminateProcess可以先用GetCurrentProcessId得到进程idj,然后调用OpenProcess得到进程的HANDLE,最后再调用TerminateProcess。
      

  4.   

    TerminateProcess就可以:
    BOOL TerminateProcess(
      HANDLE hProcess, // handle to the process
      UINT uExitCode   // exit code for the process
    );
     
      

  5.   

    TerminateProcess可以结束进程
    但最好是为这个进程创建一个窗口,并用这个窗口接收一条结束自已的消息.也就是说用另外的Exe向这个Exe的窗口发送一条类似于WM_CLOSE这样的消息,让进程自然结束
      

  6.   

    TerminateProcess()强行结束进程的运行!
      

  7.   

    TerminateProcess:
    BOOL TerminateProcess(
      HANDLE hProcess, // handle to the process
      UINT uExitCode   // exit code for the process
    );
      

  8.   

    得到一个窗口的进程IDGetWindowThreadProcessIdThe GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window. DWORD GetWindowThreadProcessId(
      HWND hWnd,             // handle to window
      LPDWORD lpdwProcessId  // process identifier
    );
      

  9.   

    GetWindowThreadProcessId
    OpenProcess
    TerminateProcess