请问各位大哥,结束当前正在运行的程序用哪个函数,我做密码认证时不知怎样结束

解决方案 »

  1.   

    PostMessage(WM_CLOSE); return;
    等~`
      

  2.   

    PostQuitMessage或者发生WM_QUIT消息
      

  3.   

    ExitProcess
    ExitThread 
    TerminateProcess 
    都可以的
      

  4.   

    如果有窗口最好是发WM_CLOSE消息。不过我估计是有的,以下几个函数最好不要使用,可能导致资源泄露。。
    ExitProcess
    ExitThread 
    TerminateProcess
      

  5.   

    这是一个自制的函数,函数体如下:Class XXX:
    {..........
    public:
    DWORD playerPid;
    ............
    }BOOL CALLBACK XXX::EnumWindowsProc(HWND hwnd, LPARAM lParam)
    {
      DWORD wndPid;
      CString Title;
      // lParam = procInfo.dwProcessId;  //  This gets the windows handle and pid of enumerated window.
      GetWindowThreadProcessId(hwnd, &wndPid);  //  This gets the windows title text from the window, using the window handle
      CWnd::FromHandle( hwnd )->GetWindowText(Title);  //  this makes sure that the PID matches that PID we started, and window
      // text exists, before we kill it . I don't think this is really needed, 
      // I included it because some apps have more than one window.
      if ( wndPid == (DWORD)lParam && Title.GetLength() != 0)
      {
        //  Please kindly close this process
        ::PostMessage(hwnd, WM_CLOSE, 0, 0);
        return false;
      }
      else
      {
        // Keep enumerating
        return true;
      }
    }
    void XXX::killProcess()
    {
    HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, FALSE, playerPid);
        //  This function enumerates all widows, using the EnumWindowsProc callback
      //  function, passing the PID of the process you started earlier.
      EnumWindows(EnumWindowsProc, playerPid);
      CloseHandle(ps);}
      

  6.   

    如果
    exit
    ExitProcess
    killProcess
    TerminateProcess 
    ExitThread
    都不行了,比如Dead loop,那就只好重新开机啦。呵呵。