Link to home
Start Free TrialLog in
Avatar of Jitu
Jitu

asked on

NT Service ?

How do i write a program that runs as a NT Service ?

Basically i want to achieve this :
I want to invoke a carry out a certain activity (liking invoking a certain application) based on time. That is, i schedule some activities for some time in future. Now, my appln. should continuosly check for time and if it is time to carry out that activity, simply do that, and continue running.

I guess, i must write a program that runs in background as a Service. But, should not be too heavy weight or hog resources.

What language has to be used...VC++ ?

How do i do this ?
Any available code ...
or info. on where i can find help on this would be helpful.

Thx.

ASKER CERTIFIED SOLUTION
Avatar of bfrancis
bfrancis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jitu
Jitu

ASKER

I want to schedule the tasks thru my program. I can do this by running the AT command everytime i want to do this, in the command window via my program.

But, is there a way, whereby i can access information about already scheduled tasks (How many etc...).
Or change or delete them thru my program ?

The information about what is already scheduled can be obtained from the registry.  Look at
HKEY_LOCAL_MACHINE\system\currentcontrolset\services\schedule
You should be able to obtain the information you need from the sub keys to tell about the scheduled tasks.  Then you can manipulate the registry, or use the AT command (/delete etc) with a winexec to manipulate it for you.
Avatar of Jitu

ASKER

Thanks Francis. I am looking into this.

But, modifying Registry values like this from what i understand is actually dangerous and not recommended.
May be i could read from the registry and modify it using the AT /delete command. Cumbersome though.

So, i am thinking whether i shud write my own appln. which runs as a service and does the job for me or use the way suggested by u.
The other thing that you can do is take an EXE that you create and run the SRVINSTW.exe which you can find on the Windows NT Re3source kit.  Te wizard will walk you through setting up a program as a service.