程序中主要是利用了setwaitabletimer.编译出错,
'CreateWaitableTimer' : undeclared identifier
SetWaitableTimer' : undeclared identifier程序如下:#include <windows.h>
#include <stdio.h>int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime; liDueTime.QuadPart=-100000000; // Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
} printf("Waiting for 10 seconds...\n"); // Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
} // Wait for the timer. if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else printf("Timer was signaled.\n"); return 0;
}
'CreateWaitableTimer' : undeclared identifier
SetWaitableTimer' : undeclared identifier程序如下:#include <windows.h>
#include <stdio.h>int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime; liDueTime.QuadPart=-100000000; // Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
} printf("Waiting for 10 seconds...\n"); // Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
} // Wait for the timer. if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());
else printf("Timer was signaled.\n"); return 0;
}
#define _WIN32_WINNT 0x0400
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
加入,可错误并没有改变。你运行能通过吗
另外,你能给我讲讲macro
#define _WIN32_WINNT 0x0400
我直接把#define _WIN32_WINNT 0x0400加入到以上示例程序
第一次编译通过了,也成功运行了。但我把它(#define _WIN32_WINNT 0x0400)往我的程序加入后,还是那些错误。于是我又重新运行msdn这个示例程序,结果错误又出现了。
重启之后多次运行示例程序都成功了,即使把它(#define _WIN32_WINNT 0x0400
)删掉,也成功运行。而我编的程序还是出错。
这究竟是什么回事,是否与marco有关,你们这么定义是什么意思。有没有相关的资料可以提供。
非常感谢