Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

control a function using another program or script


  • Please log in to reply
5 replies to this topic

#1 infinity92

infinity92

  • Members
  • 32 posts
  • OFFLINE
  •  
  • Local time:12:13 PM

Posted 11 April 2010 - 07:27 AM

hi! i'm making a timer program in C(and using some shell(batch) scripting) to limit my nephew's playing time..

i have a countdown timer that is currently programmed to lock the computer when the timer reaches 0. but the problem is that, when he shutdowns or restarts the pc, when he log-ins again to his user, the countdown timer resets again and he can play for another hour. i want to be able to save the current time to a text file and upon opening the program after a shutdown or restart, the timer continues the countdown.

my first solution for this is to save the timer's current time every second but that would be too slow.

now, i thought of this, i would disable the shutdown and restart buttons of XP in the registry and make my own shutdown and restart buttons using a script and within this script, i will instruct the timer program to save the current time and then continue with the restart or shutdown..

but i don't have any idea on how to instruct the timer program to do this, using a shell(batch) script. can you help me?

regards,
cp92.

BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:09:13 PM

Posted 11 April 2010 - 09:49 AM

my first solution for this is to save the timer's current time every second but that would be too slow.

Why would that be too slow? Have you tried it?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 infinity92

infinity92
  • Topic Starter

  • Members
  • 32 posts
  • OFFLINE
  •  
  • Local time:12:13 PM

Posted 11 April 2010 - 09:53 AM

my first solution for this is to save the timer's current time every second but that would be too slow.

Why would that be too slow? Have you tried it?

Billy3


i just thought it would be slow.. but do you think it will not be? i'm sorry i am still not that good in programming..

#4 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:09:13 PM

Posted 11 April 2010 - 11:18 AM

No, I don't think it would be slow. If you keep the file in question open than the O/S is going to cache the disk writes for you, and even if it wasn't, a typical hard disk can do:

(1 second) / (16 milliseconds) = 62.5 random access reads/writes per second.

meaning your app is using less than 2% of hard disk access time, even if no caching was involved. CPU time will be negligible.

You could also write the end time into the file instead, and read the end time once on startup.
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#5 infinity92

infinity92
  • Topic Starter

  • Members
  • 32 posts
  • OFFLINE
  •  
  • Local time:12:13 PM

Posted 11 April 2010 - 05:53 PM

You could also write the end time into the file instead, and read the end time once on startup.


How do i do this?

#6 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:09:13 PM

Posted 11 April 2010 - 06:31 PM

Err.. instead of writing "10 minutes left" into the file, you'd figure out what now + 10 minutes is, and write that date and time instead. Then you don't need to keep updating the file.
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users