我在线程中调用了
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.
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.
解决方案 »
- http下载,怎样判断要下载的文件是否支持断点续传?即可以使用http的range域。
- 关于进度条的问题
- VC通过socket发送数据给java的问题
- [请教]为什么我的钩子成功挂接到QQ的RichEdit线程了,却不执行钩子过程?
- 请教c++高手, 对于一些自已写的.h头文件,如果多次包含就会发生重复.详情讲进来看看.........
- 怎样在不改源代码的情况下,把发往串口的数据,转发给网络?
- 我想在VC下面实现多个客户端连接一个服务端,出问题了,请大家帮帮忙。。。
- 如何让指定窗口置前?
- 求助:关于AfxMessageBox的用法
- 高手请看:如何自动添加打印机驱动?像acrobat一样!急!
- 如何写程序注册一个ocx呢?
- 超级奇怪问题!!救济啊!!!
#define WIN32_WINNT 0x0500
函数是在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
_WIN32_WINNT 默认非0x0400
见笑!
Sleep(0)就可以了
在windows NT4.0及更高的版本中,通过调用::SwitchToThread可以执行另一个线程,如果编写的程序必须运行在所有的Win32平台上,就要使用::Sleep(0);
因为我对时间的要求高,sleep最小精度是50MS,满足不了
后来是用MMTIMER解决的
谢谢各位