I want to call Sleep(x), where x is milliseconds to sleep. I know this is the function, but it doesn't work for me. What do I need to include?
我想调用Sleep(x),其中x是睡眠的毫秒数。我知道这是功能,但它对我不起作用。我需要包括什么?
---SOLVED---
I was using the compiler option /Za, which disabled the native Windows extensions used in Sleep()'s implementation.
我使用的是编译器选项/ Za,它禁用了Sleep()实现中使用的本机Windows扩展。
5 个解决方案
#1
Sleep is defined in Winbase.h, but you should include Windows.h to get it.
Sleep是在Winbase.h中定义的,但是你应该包含Windows.h来获取它。
In the future you can find your information for yourself by bringing up the Help from VisualStudio or searching MSDN. All such info on Win32 API calls should be in there.
将来,您可以通过调出VisualStudio的帮助或搜索MSDN来找到自己的信息。有关Win32 API调用的所有此类信息都应该在那里。
#2
Sleep Using WINAPI Sleep(__in DWORD dwAtleastFor8HoursForGoodHealth);
睡眠使用WINAPI睡眠(__在DWORD dwAtleastFor8HoursForGoodHealth中);
Include Winbase.h or Windows.h
包括Winbase.h或Windows.h
#3
you just Sleep(asManyMilliSecondsAsYouWant);
你只是睡觉(asManyMilliSecondsAsYouWant);
#4
Sleep(int milliseconds) is a Win32 API to suspend execution of your program for the set number of milliseconds.
Sleep(int milliseconds)是一个Win32 API,用于暂停程序执行的设定毫秒数。
Include <windows.h>
to get access to it.
包含
MSDN usually lists what header files and libraries API's are in.
MSDN通常列出了API所在的头文件和库。
#5
This might be a bit too late (for the 'asker' :)), but in MSVC (2010) (console application) the sleep is in SECONDS not Milliseconds.
这可能有点太晚了(对于'asker':)),但在MSVC(2010)(控制台应用程序)中,睡眠是在SECONDS而不是毫秒。
#1
Sleep is defined in Winbase.h, but you should include Windows.h to get it.
Sleep是在Winbase.h中定义的,但是你应该包含Windows.h来获取它。
In the future you can find your information for yourself by bringing up the Help from VisualStudio or searching MSDN. All such info on Win32 API calls should be in there.
将来,您可以通过调出VisualStudio的帮助或搜索MSDN来找到自己的信息。有关Win32 API调用的所有此类信息都应该在那里。
#2
Sleep Using WINAPI Sleep(__in DWORD dwAtleastFor8HoursForGoodHealth);
睡眠使用WINAPI睡眠(__在DWORD dwAtleastFor8HoursForGoodHealth中);
Include Winbase.h or Windows.h
包括Winbase.h或Windows.h
#3
you just Sleep(asManyMilliSecondsAsYouWant);
你只是睡觉(asManyMilliSecondsAsYouWant);
#4
Sleep(int milliseconds) is a Win32 API to suspend execution of your program for the set number of milliseconds.
Sleep(int milliseconds)是一个Win32 API,用于暂停程序执行的设定毫秒数。
Include <windows.h>
to get access to it.
包含
MSDN usually lists what header files and libraries API's are in.
MSDN通常列出了API所在的头文件和库。
#5
This might be a bit too late (for the 'asker' :)), but in MSVC (2010) (console application) the sleep is in SECONDS not Milliseconds.
这可能有点太晚了(对于'asker':)),但在MSVC(2010)(控制台应用程序)中,睡眠是在SECONDS而不是毫秒。