我在线程中调用了
SwitchToThread();
但编译时出错
C:\Documents and Settings\argus\桌面\ee\eeDlg.cpp(99) : error C2065: 'SwitchToThread' : undeclared identifier我在StdAfx.h中加入了#ifndef  _WIN32_WINNT  
#define  _WIN32_WINNT  0x0400  
#endif#include "winbase.h"//去掉也试过,都不行请大家帮我看看是什么回事MSDN的说明如下:
witchToThread
The SwitchToThread function causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.BOOL SwitchToThread(VOID)
 
Parameters
This function has no parameters. Return Values
If calling the SwitchToThread function causes the operating system to switch execution to another thread, the return value is nonzero. If there are no other threads ready to execute, the operating system does not switch execution to another thread, and the return value is zero. Res
The yield of execution is in effect for up to one thread-scheduling time slice. After that, the operating system reschedules execution for the yielding thread. The rescheduling is determined by the priority of the yielding thread and the status of other threads that are available to run. Note  The yield of execution is limited to the processor of the calling thread. The operating system will not switch execution to another processor, even if that processor is idle or is running a thread of lower priority. QuickInfo
  Windows NT: Requires version 4.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.

解决方案 »

  1.   

    你用的是什么操作系统?只有2000才支持这个函数,2000以前的版本不支持
    #define WIN32_WINNT  0x0500  
      

  2.   

    应该是只有WIN2K以上的系统才支持
      

  3.   

    我W2K SERVER和Professional都试了,都不行
      

  4.   

    刚才查了一下这个函数需要platform SDK!
    函数是在kernel32.dll里,对系统要求很松,NT系列的都行:一些定义:Minimum system required Macros to define 
    Windows Server 2003 family _WIN32_WINNT>=0x0502 
    Windows XP _WIN32_WINNT>=0x0501 
    Windows 2000 _WIN32_WINNT>=0x0500 
    Windows NT 4.0 _WIN32_WINNT>=0x0400 
    Windows Me _WIN32_WINDOWS=0x0490 
    Windows 98 _WIN32_WINDOWS>=0x0410 
    Internet Explorer 6.0 _WIN32_IE>=0x0600 
    Internet Explorer 5.01, 5.5 _WIN32_IE>=0x0501 
    Internet Explorer 5.0, 5.0a, 5.0b _WIN32_IE>=0x0500 
    Internet Explorer 4.01 _WIN32_IE>=0x0401 
    Internet Explorer 4.0 _WIN32_IE>=0x0400 
    Internet Explorer 3.0, 3.01, 3.02 _WIN32_IE>=0x0300 
      

  5.   

    _WIN32_WINNT = 0x0400  
    _WIN32_WINNT 默认非0x0400
    见笑!
      

  6.   

    可以不使用这个函数
    Sleep(0)就可以了
      

  7.   

    同意 bluebohe(薄荷) !
    在windows NT4.0及更高的版本中,通过调用::SwitchToThread可以执行另一个线程,如果编写的程序必须运行在所有的Win32平台上,就要使用::Sleep(0);
      

  8.   

    问题已解决,不过是通过其它方法
    因为我对时间的要求高,sleep最小精度是50MS,满足不了
    后来是用MMTIMER解决的
    谢谢各位