开发者

Can we use a timer for itself?

Actually this is what i want to do;

When a condition appears, 开发者_C百科my program will close itself and after five minutes it will re-open.

Is it possible with only one .exe -by using any OS property-?

I do it with two .exe

if (close_condition){
     //call secondary program
     system ("secondary.exe");
     return (0);
}

and my secondary program just waits for five minutes and calls the primary one.

main (){
     Sleep (300000)//sleep for five minutes;
     system ("primary.exe");
     return (0);
}

i want to do it without secondary program.

(sorry for poor english)


You can do it with one application that simply has different behaviour if a switch is given (say myapp.exe /startme).

system() is a synchronous call by the way, it does only return when the command run is finished. In win32 CreateProcess() is what you are looking for.

You can also just follow Jays suggestion of letting the OS schedule your job using NetScheduleJobAdd().

But, depending on what you're trying to achieve, a better solution might be to simply hide your application for 5 minutes.


I think you'd have to use the system task scheduler to schedule the re-launch, which in a sense is using another application, but one that is part of the OS.

I'm sure this can be done, but frankly I think you should just stick with your current setup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜