如题。关键是想确保已经SetTimer!
解决方案 »
- vc++2008如何获取控制面板中网络连接的所有连接以及连接的属性
- [100分奉上] CHtmlView中怎样得到当前网页的标题?(<title></title>)
- UI新手提问:还是在VC里SDI下,视图分割的问题,我分割完成了,想这样实现功能,请问怎么解决?
- 怎么为MDI主窗口的客户区加一个随客户区大小一起伸缩的背景?谢谢
- 当我用VC6.0 连接Access数据库时总是出现以下"警告", 请问这个"警告"是什么意思? 我需要去理会这个"警告"吗?
- 关于CButton的一个简单问题
- 如何在对话框内画圆并移动?
- 请问能不能通过对方主机名找到对方的IP地址???????
- 哪里有基于Windows平台的SNMP协议的网管软件源代码例子,谢谢!!!
- 安装.net的时候遇到的问题
- 利用二叉树写的实数计算器, 请大家提提意见
- CObArray m_Info; 怎么在dll中用呢 ??出现的 error : missing ';' before identifier 'm_Info'
你kill的时候就使用这个id。 不会kill出问题的。
killtimer也没事的不过你的逻辑是很值得赞同的
Return ValueIf the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer. If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.
直接 KillTimer 就行,不存在它就直接返回一个错误!
{
InterlockedExchange(&IsTimerSet,1); // IsTimerSet为1时,就是SetTimer成功了
}// KillTimer前
LONG volatile CurrentValue = 0;
InterlockedExchange(&CurrentValue,IsTimerSet);
if (CurrentValue)
{
KillTimer()
}这只是一种好的编程习惯,KillTimer()就算删除不存在的Timer,也不会返回任何错误,因为KillTimer()会先查看是否有这个Timer,然后再Kill掉,如果没查到有这个Timer,自然不会删除了.