| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1497 人关注过本帖
标题:[求助]怎么编写定时程序
只看楼主 加入收藏
yydksx
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-1-17
收藏
 问题点数:0 回复次数:15 
[求助]怎么编写定时程序

我编了一个程序.
#include <windows.h>
using namespace std;
main()
{
system("c:\\progra~1\\intern~1\\iexplore.exe www.sina.com.cn");
return 0;
}
我想让它在12:00钟运行,加什么代码?
或者倒计时,在运行程序后20秒打开网页,怎么实现?
谢谢指教.

搜索更多相关主题的帖子: sina windows 编写 网页 
2006-06-03 08:56
myajax95
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:30
帖 子:2978
专家分:0
注 册:2006-3-5
收藏
得分:0 
如果你的程序有Window的话,可以生成一个从CWnd派生出来的class。在里面SetTimer(),然后用OnTimer()响应。如果没有window可以另起一个thread,在里面sleep()值到12点。

当然你也可以单线程操作。直接sleep至12点,这样作程序本身就不能作任何即时的任务了。

http://myajax95./
2006-06-03 10:11
ooooo
Rank: 1
等 级:新手上路
威 望:1
帖 子:135
专家分:0
注 册:2005-6-24
收藏
得分:0 

系统有一个at命令
这个命令的语法是
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername 指定远程计算机。 如果省略这个参数,
会计划在本地计算机上运行命令。
id 指定给已计划命令的识别号。
/delete 删除某个已计划的命令。如果省略 id,
计算机上所有已计划的命令都会被删除。
/yes 不需要进一步确认时,跟删除所有作业
的命令一起使用。
time 指定运行命令的时间。
/interactive 允许作业在运行时,与当时登录的用户
桌面进行交互。
/every:date[,...] 每个月或每个星期在指定的日期运行命
令。如果省略日期,则默认为在每月的
本日运行。
/next:date[,...] 指定在下一个指定日期(如,下周四)运
行命令。如果省略日期,则默认为在每
月的本日运行。
"command" 准备运行的 Windows NT 命令或批处理
程序。


2006-06-04 21:09
wangxiang
Rank: 2
等 级:新手上路
威 望:5
帖 子:376
专家分:0
注 册:2006-3-28
收藏
得分:0 

还是不知道怎么去实现

2006-06-04 22:08
云中雾
Rank: 1
等 级:新手上路
威 望:1
帖 子:168
专家分:3
注 册:2005-12-30
收藏
得分:0 

用DOS下的at命令


白色的忧郁让我白色的思念从洁白到苍白,从苍白到空白,比空白更空白,变成深白的坦白!
2006-06-05 15:29
秦始皇
Rank: 1
等 级:新手上路
威 望:1
帖 子:941
专家分:0
注 册:2006-5-26
收藏
得分:0 

汝等可定义之谓之线程也,线程控之真好也


普天之下 皆朕之子民也 汝知乎?
2006-06-05 17:47
janlun86
Rank: 1
等 级:新手上路
帖 子:89
专家分:0
注 册:2006-5-9
收藏
得分:0 
以下是引用秦始皇在2006-6-5 17:47:00的发言:

汝等可定义之谓之线程也,线程控之真好也

古人也识编程否


天道酬勤,切忌浮躁
2006-06-06 22:21
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
yydksx,

haha, I think you maybe someone that I know.
do you want be hacker?
You should know, hacker is such one, who like freedom and be helpful for someone else, not such one, who write virus and make attack to someone else. When you really like programming and want be hacker, you should maybe see this link:
http://www.catb.org/~esr/faqs/hacker-howto.html

when you want gut learn c/c++ you should use gcc compiler.
Within gcc compiler you can enter g++ -o exefilename programname.cpp // for example
then you will have an executeable file with name exefilename.exe unter windows, under linux he will named exefilename.out
To run this file, you should just type exefilename

when you want work with IDE, my suggestiong for you is DEV which using gcc compiler intern.

try this code:
[CODE]
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;

void getCurrentTime(int & h, int & m, int & s)
{
time_t curr;
tm local;
time(&curr); // get current time_t value
local=*(localtime(&curr)); // dereference and assign

if(local.tm_isdst == 1)
{
h = local.tm_hour;
m = local.tm_min;
s = local.tm_sec;
}
else
{
h = -1;
m = -1;
s = -1;
}
}

int main()
{
int h, m, s;
bool fail = false;
do
{
getCurrentTime(h, m, s);

// here is the time, at that you want to start some other program
// for example 19:55:00 - 19:55:05
// why s<5?
// the program to run take also some time, so
// it is better to set an guarantee
if(h == 19 && m == 55 && s<5)
break;
else if(h == -1 || m == -1 || s == -1)
{
fail = true;
break;
}
}while(true);

if(!fail)
{
cout<<"current time is "<<h<<":"<<m<<":"<<s<<endl;
system("c:\\progra~1\\intern~1\\iexplore.exe www.kaisoftworld.de");
}

return 0;
}

[/CODE]

自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-06-07 02:02
stylev
Rank: 1
等 级:新手上路
威 望:1
帖 子:136
专家分:0
注 册:2006-5-30
收藏
得分:0 

You should know, hacker is such one, who like freedom and be helpful for someone else, not such one, who write virus and make attack to someone else.


support!!!

E-mail/MSN: stylev@
2006-06-07 03:09
wfpb
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2188
专家分:0
注 册:2006-4-2
收藏
得分:0 
You should know, hacker is such one, who like freedom and be helpful for someone else, not such one, who write virus and make attack to someone else.


It's also my opinion!

[glow=255,red,2]wfpb的部落格[/glow] 学习成为生活的重要组成部分!
2006-06-07 08:53
快速回复:[求助]怎么编写定时程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012775 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved