VC中,我想让一段程序运行一段时间就停止,怎么办

来源:百度知道 编辑:UC知道 时间:2024/06/20 06:30:04
用SetTimer的话是每隔一段时间运行一次,
我就想让程序运行一次怎么办,用SetTimer显得太麻烦了
谢谢大家了

#include <windows.h>

system("pause");

让程序暂停

你的问题不太清楚:还可以通过BOOL型数据实现,bool brun = false; 运行完后brun = true;
if( !brun )
{
.....
//运行一次的程序段
}

SetTimer(1,10000,null)
然后在OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
exit(0); 或者 sendmessage(wm_close);
}

用其它方法会更麻烦~