自己在外部设置变量来标记吧。如: m_bSuspend = FALSE;调用SuspendThread之后把m_bSuspend设置为TRUE调用ResumeThread之后把m_bSuspend设置为FALSE以后要查询是不是挂起,只要看这个变量就好了

解决方案 »

  1.   

    楼上 怎么这么能扯淡
    调用SuspendThread之后把m_bSuspend设置为TRUE 
    你怎么能做到这一点呢
      

  2.   

    我个人认为这种情况基本上不可能实现判断一个线程是否执行中,比如A线程用来监视B线程的状态,在单CPU下,一个时刻只有一个线程是被调度的,A线程调用一个函数用来监视,即A线程会阻塞在那,当B线程运行时A线程是被阻塞在那的,A线程要想监视成功,一定是B线程的运行通过硬件信号来激活A线程,这样A线程的监视函数才能返回,得到我们想要的结果,而此时B线程却被阻塞了,这样我们就不能说B线程是运行中,这只是我的个人之见,我不知道你想要实现个什么功能,你可以换一种解决方法嘛,不一定非要获得线程的运行与挂起状态!
      

  3.   

    调用resumetthread,查看返回值  
      

  4.   

    调用resumetthread,查看返回值 ++
      

  5.   

    SuspendThread
    The SuspendThread function suspends the specified thread. DWORD SuspendThread(
      HANDLE hThread   // handle to the thread
    );
     
    Parameters
    hThread 
    Handle to the thread. 
    Windows NT: The handle must have THREAD_SUSPEND_RESUME access. Return Values
    If the function succeeds, the return value is the thread's previous suspend count; otherwise, it is 0xFFFFFFFF. To get extended error information, use the GetLastError function.