在线等:如何在控制台程序中使用多个定时器 如题,谢谢各位兄弟姐妹 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #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;} 我用的是一种比较笨的方法,比如一个是10毫秒,一个是100毫秒,那就使用一个10毫秒的时钟,并定义一个int型time100,在写处理10毫秒的函数加:time100++;if(time100==10){ //处理100毫秒的函数 time100=0;} 请教程事件问题 Ipheader的checksum总是算不对,求解释。 请问局部键盘钩子(内程内)可以监视所有线程吗 sendmessage不起作用 如何在不重启程序的情况下,重新打开主窗口 菜鸟学习数据库编程问题之-001 100分求解,用代码打开word文档,怎样捕获打开不成功的错误? 变量传递 程序运行中内存引用错误。可能是什么问题? 关于软件加密问题 #define WINVER 0x0500 起什么作用? 有人碰到过这样的问题没?
#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;
}
time100++;
if(time100==10){
//处理100毫秒的函数
time100=0;
}