热烈庆祝本人受关注人数即将突破12000大关!散分!!

赵4老师 2017-02-06 11:49:01
加精
祝C/C++er们2017 Hold住*.* !
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
HANDLE gDoneEvent;
VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) {
if (lpParam == NULL) {
printf("TimerRoutine lpParam is NULL\n");
} else {
// lpParam points to the argument; in this case it is an int
printf("Timer routine called. Parameter is %d.\n", *(int*)lpParam);
}
SetEvent(gDoneEvent);
}
int main() {
HANDLE hTimer = NULL;
HANDLE hTimerQueue = NULL;
int arg = 123;

// Use an event object to track the TimerRoutine execution
gDoneEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (NULL == gDoneEvent) {
printf("CreateEvent failed (%d)\n", GetLastError());
return 1;
}

// Create the timer queue.
hTimerQueue = CreateTimerQueue();
if (NULL == hTimerQueue) {
printf("CreateTimerQueue failed (%d)\n", GetLastError());
return 2;
}

// Set a timer to call the timer routine in 10 seconds.
if (!CreateTimerQueueTimer( &hTimer, hTimerQueue, (WAITORTIMERCALLBACK)TimerRoutine, &arg , 10000, 0, 0)) {
printf("CreateTimerQueueTimer failed (%d)\n", GetLastError());
return 3;
}

// TODO: Do other useful work here
printf("Call timer routine in 10 seconds...\n");

// Wait for the timer-queue thread to complete using an event
// object. The thread will signal the event at that time.

if (WaitForSingleObject(gDoneEvent, INFINITE) != WAIT_OBJECT_0)
printf("WaitForSingleObject failed (%d)\n", GetLastError());

CloseHandle(gDoneEvent);

// Delete all timers in the timer queue.
if (!DeleteTimerQueue(hTimerQueue))
printf("DeleteTimerQueue failed (%d)\n", GetLastError());

return 0;
}
//Call timer routine in 10 seconds...
//Timer routine called. Parameter is 123.
//
...全文
8478 125 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
125 条回复
切换为时间正序
请发表友善的回复…
发表回复
look19940509 2019-03-04
  • 打赏
  • 举报
回复
大佬。。。。。。。。
quanxinxiaobai 2019-02-27
  • 打赏
  • 举报
回复
我刚接触这个,还有很多不懂,希望能有人指点我。我可能问题比较多,因为菜了点,希望能加我微信,嘻嘻
小巨人婕如 2019-02-14
  • 打赏
  • 举报
回复
第一次进CSDN 默默试试
  • 打赏
  • 举报
回复
Dreamy~ 2019-01-05
  • 打赏
  • 举报
回复
这真的是新手乐园吗到处都是大佬
我好高冷 2018-12-29
  • 打赏
  • 举报
回复
大神牛逼~已关注!!!
ZyuLai 2018-12-15
  • 打赏
  • 举报
回复
weixin_43345092 2018-12-11
  • 打赏
  • 举报
回复
赵老师,程序出现问题了,可以请教您吗?
maksim keyboarder 2018-12-07
  • 打赏
  • 举报
回复
去年的了?
flcnrcn 2018-12-06
  • 打赏
  • 举报
回复
膜拜大神……………………
  • 打赏
  • 举报
回复
赵4老师,能否帮忙看下C++托管类的问题? 谢谢! C#调用C++托管类出现not supported by the language的错误。 问题链接https://bbs.csdn.net/topics/392487346
qq_27324295 2018-12-03
  • 打赏
  • 举报
回复
分数有点少了
脸ル粉嘟嘟 2018-11-23
  • 打赏
  • 举报
回复
chengweigege 2018-09-20
  • 打赏
  • 举报
回复
黑刀夜 2018-08-17
  • 打赏
  • 举报
回复
关注赵四老师
mirage3776 2018-08-15
  • 打赏
  • 举报
回复
斜杠青年/ 2018-08-12
  • 打赏
  • 举报
回复
~ ~
~~~~~~~~~~~~~!!
weixin_35737493 2018-08-08
  • 打赏
  • 举报
回复
  • 打赏
  • 举报
回复
在网上回答问题的,是赵老师的AI机器人吧!
dddcode 2018-04-07
  • 打赏
  • 举报
回复
才开始学c,希望给力,啦啦啦
加载更多回复(105)

70,022

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧