如何调用计划任务程序,让系统定期执行我的程序(50分)

  • 主题发起人 主题发起人 xaosduck
  • 开始时间 开始时间
X

xaosduck

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,不知该调用哪个 API,是不是netschedulejobadd,how to use it.
 
应该由数据库实现,不知用的是什么数据库?
 
可以自己编一个小控件<br>定时触发任务事件,<br>若为非精确计时,直接使用TIMER事件<br>即可,若要精确计时可使用子线程<br>用SLEEP实现,本人曾编过一个非精确<br>计时的定时触发组件,很粗糟,如需要<br>可MAIL去供指点
 
type <br>&nbsp; TAT_INFO = record<br>&nbsp; &nbsp; JobTime: DWord;<br>&nbsp; &nbsp; DaysOfMonth: DWord;<br>&nbsp; &nbsp; DaysOfWeek: UCHAR;<br>&nbsp; &nbsp; Flags: UCHAR;<br>&nbsp; &nbsp; Command: PWideChar;<br>&nbsp; end;<br><br>&nbsp; PAT_INFO = ^TAT_INFO;<br>&nbsp; NET_API_STATUS = LongInt;<br>function NetScheduleJobAdd(ServerName: PWideChar; Buffer: PAT_INFO; var JobID: LongInt): NET_API_STATUS; external 'netapi32.dll' name 'NetScheduleJobAdd';<br><br><br>Parameters<br><br>Servername<br><br>Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.<br><br>Buffer<br><br>Pointer to a buffer containing an AT_INFO structure describing the job to be submitted.<br><br>JobId<br><br>Pointer to a job identifier for a newly submitted job. This entry is valid only if the function returns successfully.<br><br>AT_INFO:<br>Members<br><br>JobTime<br><br>Time of day at which a job is scheduled to run. Time is a local time at a computer on which the Schedule service is running. Time is measured from midnight and is expressed in milliseconds.<br><br>DaysOfMonth<br><br>Bitmask for the days of the month on which a job is scheduled to run. The bitmask is NULL if a job was scheduled to run only once at the first occurrence of JobTime. For each bit that is set in the bitmask a job will run at JobTime on a corresponding day of the month. Bit 0 corresponds to the first day of the month, and so on.<br><br>DaysOfWeek<br><br>Bitmask for the days of the week on which the job is scheduled to run. The bitmask is NULL if a job was scheduled to run only once at the first occurrence of JobTime. For each bit that is set in the bitmask a job will run at JobTime on a corresponding day of the week. Bit 0 corresponds to Monday (first day of the week), and so on.<br><br>Flags<br><br>Bitmask describing job properties. For job submission (NetScheduleJobAdd), the possible values are:<br><br>JOB_RUN_PERIODICALLY<br><br>If this flag bit is set, the job runs on every day for which corresponding bits in DaysOfMonth or DaysOfWeek are set. If this flag bit is clear, then job runs only once for each bit that was set in DaysOfMonth or DaysOfWeek at the time of job submission.<br><br>JOB_ADD_CURRENT_DATE<br><br>When this flag bit is set, the job will also execute at the first occurrence of JobTime at the computer to which the job is submitted. In other words, setting this flag bit is equivalent to setting the corresponding day bit in the DaysOfMonth bitmask.<br><br>For job information retrieval (NetScheduleJobEnum and NetScheduleJobGetInfo), possible values are:<br><br>JOB_RUN_PERIODICALLY<br><br>This flag bit is equal to the original value of this flag bit when a job was submitted.<br><br>JOB_EXEC_ERROR<br><br>This flag bit is set whenever Schedule service failed to successfully execute this job the last time it was supposed to run.<br><br>JOB_RUNS_TODAY<br><br>This flag bit is set if JobId is larger than the current time of day at the computer at which this job is queued.<br><br>Command<br><br>Pointer to a Unicode string that contains the name of the command, batch program, or binary file to execute.<br>&nbsp;
 
可以编一个定时提醒的程序.我有Task.它能定时提醒和运行程序并带名片管理.<br>&lt;a href="http://sunhy.126.com" target="_blank"&gt;&lt;font size="2" color="#0000FF"<br>face="宋体"&gt;http://sunhy.126.com&lt;/font&gt;&lt;/a&gt;
 
不知道怎样看的问题,牛头不对马嘴,sorry.
 
sunstone,你的程序是怎么判断运行时间到了?<br>
 
放一个timer,然后再ontime中处理事件..具体思路是这样的:<br>假如有多个任务需要提醒,把这些任务的时间放到一个数组中并排序.<br>设置timer的时间频率,并在ontime中检查是否第一个到时间了.如果到了,执行任务.<br>数组序号加1.接着检查.<br>请下载task试一试,看看是不是你想要的东西.
 
可以将程序放在启动中<br>系统启动后自动执行<br>在利用时间条件判断执行
 
我的解决方法:<br>前提是你用的操作系统有计划任务<br>你可以在程序中直接得到windows系统的路径<br>再在Tasks目录下加上一个你的任务<br>你可以先做好一个你自己的yous.job<br>然后将其拷到Tasks目录下面,如果你的安装目录改变的话<br>可以自己分析*.job文件的格式,用你的程序进行修改,只要<br>把Job文件中有的路径信息改掉就可以用了
 
多人接受答案了。
 
??怎么这样就结束了<br>JOB的格式呢?
 
后退
顶部