系统时间改变时我能否得到系统消息

sdc_sh 2003-08-21 04:41:56
我正在做一个按计划执行指定任务的程序,现在我是程序开始运行时读了系统时间,
然后根据设置的计划(也就是按一定的时间间隔执行任务)执行任务,但我想如果程序运行过程中修改了系统时间,则我的程序计划任务执行就可能出差错,我想最好不需我在程序中定时与系统时间同步,不知系统时间更改时我能否得到消息,这样我就可在我的程序里修正时间。
...全文
56 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
思危 2003-08-22
  • 打赏
  • 举报
回复
WM_TIMECHANGE
An application sends the WM_TIMECHANGE message whenever it updates the system time.

To send this message, call the SendMessage function with the following parameters.

SendMessage(
(HWND) hWnd, // handle to destination window
WM_TIMECHANGE, // message to send
(WPARAM) wParam, // not used; must be zero
(LPARAM) lParam // not used; must be zero
);
Parameters
This message has no parameters.

Return Values
An application should return zero if it processes this message.

Remarks
To send this message to all top-level windows, an application can use the SendMessage function with the hWnd parameter set to HWND_TOPMOST.

Windows 2000/XP: An application should not broadcast this message, because the system will broadcast this message when the application changes the system time.

Windows NT 4.0 and earlier: An application should send this message to all top-level windows after changing the system time.

Windows 95/98/Me: An application should send this message to all top-level windows after changing the system time.

思危 2003-08-22
  • 打赏
  • 举报
回复
响应:
WM_TIMECHANGE

看MSDN
nicepose 2003-08-22
  • 打赏
  • 举报
回复
精度不高的话用OnTimer啊

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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