gpt4 book ai didi

c - 为什么 setTimer 不起作用?

转载 作者:太空宇宙 更新时间:2023-11-04 00:16:47 25 4
gpt4 key购买 nike

<分区>

我有以下程序。我想知道 setTimer 是如何工作的。所以,我写了一个程序,但无法理解为什么 TimerProc 函数没有被调用。为什么?还需要做什么来触发 setTimer/TimerProc。请帮忙。

#include <windows.h>
#include <stdio.h>

VOID CALLBACK TimerProc(
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
) {
printf("from callback\n");

}
int main(int argc, char *argv[])
{
UINT timerid = SetTimer(NULL,1,1000,TimerProc);/*changed the time from 1 to 1000, but no effect*/
printf("timerid %d\n",timerid);
int i,j;

//delay loop, waiting for the callback function to be called
for(j=0;j<0xffffffff;j++);
/*{
printf("%d\n", j);
}*/

printf("done \n");
system("PAUSE");
return 0;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com