c++控制台程序实现定时器
来源:互联网 发布:怎么搜索微博域名 编辑:程序博客网 时间:2024/05/22 08:13
#include "stdafx.h" #include <iostream> #include <Windows.h> using namespace std; void CALLBACK TimeProc(HWND hwnd,UINT message,UINT idTimer,DWORD dwTime); int _tmain(int argc, _TCHAR* argv[]) { SetTimer(NULL,1,1000,TimeProc); MSG msg; while (GetMessage(&msg,NULL,0,0)) { if (msg.message == WM_TIMER) { DispatchMessage(&msg); } } return 0; } int ncount = 0; void CALLBACK TimeProc(HWND hwnd,UINT message,UINT idTimer,DWORD dwTime) { cout<<ncount++<<endl; } /* 何问起 hovertree.com */
#include "stdafx.h" #include <ctime> #include <Windows.h> #include <conio.h> #include <stdio.h> int ncount = 0; void CALLBACK TimerProc(HWND hWnd,UINT nMsg,UINT_PTR idEvent,DWORD dwTime) { ncount++; } DWORD CALLBACK Thread(PVOID pvoid) { MSG msg; PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE); UINT timerid = SetTimer(NULL,1,10000,TimerProc); BOOL bRet; while ((bRet = GetMessage(&msg,NULL,0,0)) != 0) { if (bRet == -1) { printf("Error:the thread will quit,error id is %d/n",GetLastError()); break; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } KillTimer(NULL,timerid); printf("thread end here/n"); return 0; } int _tmain(int argc, _TCHAR* argv[]) { HANDLE hThread = CreateThread(NULL,0,Thread,NULL,0,NULL); _getch(); return 0; } /* 何问起 hovertree.com */
点击打开链接
0 0
- c++控制台程序实现定时器
- c++控制台程序实现定时器
- c++控制台程序实现定时器
- Win32控制台程序的定时器实现
- Win32控制台程序的定时器实现
- Win32控制台程序的定时器实现 多媒体定时器
- C#定时器【控制台程序】
- [C-C++]控制台用定时器
- 控制台程序中使用定时器
- VC++控制台程序中使用定时器
- C++控制台程序中使用定时器
- C++控制台程序中使用定时器
- VC++控制台程序中使用定时器
- VC++控制台程序中使用定时器
- VC++控制台程序中使用定时器
- 在Win32控制台程序中使用定时器
- VC++控制台程序中使用定时器
- 求win32下的多线程控制台程序(c实现)
- SpringMVC controller层模板
- lintcode(384)最长无重复字符的子串
- WebRTC常用知识点
- DPDK学习笔记<4>源代码分析(1)
- web网站嵌入QQ临时会话代码
- c++控制台程序实现定时器
- Android事件分发机制详解:史上最全面、最易懂
- 线性代数mooc课(3.2)
- 敏感词的简单实现
- 数据库邮件
- 2017.4.8第五次測試總結
- 获取表字段名用于insert into语句
- 高效编程之首字符大小写转换!
- C++ 标识符的作用域