?
Solved

How to write an NT Service

Posted on 1997-06-16
12
Medium Priority
?
254 Views
Last Modified: 2010-05-18
Simple.
How do you write an NT Service?
How do you declare it as such to NT?
I assume the former is some type of DLL with certain declared functions, and the latter is a regisrty key, but some details would be useful!
(BTW the MS Development library seems to have no help on this subject...)
0
Comment
Question by:bcrotaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
12 Comments
 

Expert Comment

by:brittain
ID: 1337091

Not so simple.

You're assumptions are fairly accurate.  Should be EXE.  The registry has entries (look HKEY_LOCAL_MACHINE \ System \ ControlSetXXX \ Services), but generally there are WinAPI routines to write them.

MSDN does have quite a bit on services.  Try searching for Service Control Manager, OpenSCManager(), CreateService(), etc.  Also, there is a helpful example of a COM based service named SECSVR.CPP on MSDN.

Coincidentally, I asked a Borland SE about built in support for services and he said it was coming, but had no definitive timeframe (next version???).

I realize this isn't a "solution", but to write a service you've quite a bit of research to do (read "security, threading, etc.).  FYI, we are planning work in this area and would be interested in talking about it offline.
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1337092
MSDN?
It would be nice to write a wizard/ drop-on component to create a service.
Maybe I'll look at that when I'm done.
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1337093
Actually, I'm not hugely worried about security etc, due to the very simple nature of the app.
It's just backing up certain files every so often.
The client tells it what and where.
It's a service so that it starts automatically.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:bcrotaz
ID: 1337094
I think I need more help on this one.
Thanks for the ideas, maybe someone else has already done this in Delphi.
0
 

Expert Comment

by:brittain
ID: 1337095
Try the Delphi Super Page (http://sunsite.icm.edu.pl/delphi/).  I saw a component there from someone in Minsk.  The source is supposed to be available.  I've tried it, but it doesn't run under NT 4.0.

Even if you're not interested in "securing" your application, you need to look into NT security.  One of the biggest pains with writing NT services is the authentication / identity rules imposed by the NT Security Manager.
0
 
LVL 3

Expert Comment

by:sperling
ID: 1337096
You don't need to bother with security to get a basic service up and running. To backup files, however, you need an account and password that has access to the files to backup.

There's a lot of work required to get a service working properly using Delphi, especially if your app has any direct or indirect reference to the forms.pas unit, and therefore instantiates the Application object. See the question "NT Services and Delphi 2" in the "Previously Answered Questions" section for a unit containing the necessarry declarations. I also tried to explain how services work and are started/controlled in the answer to this question.

Regards,

Erik.
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1337097
Aha!
Thanks.
I should have looked, really, shouldn't I?
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1337098
Erm...
It's not simple really, is it?
Do you know how to get hold of the component you talk about in the paq?
0
 
LVL 3

Expert Comment

by:sperling
ID: 1337099
It's not as simple as dropping components on a form and setting properties ;) It is a lot simpler than writing a device driver, a debugger or some tcp/ip server....

My comments on the PAQ merely tried to explain the order in which certain events takes place when a service is started and controlled. You'll need some trying and failing to get it running, but it is not very complicated once you grasp how the SCM executes and controls the service.

I don't know the current status of ServiceMaker, I just tested an early beta, but if it has been released you should find a post on usenet in the comp.lang.pascal.delphi.announce group.
 
I am planning to assemble a service skeleton and put it up on my web page, but it won't be done until sometime in august I believe. I seem to rememeber at least 3 or 4 different service examples posted on news, try searching with dejanews and you might come up with some useful links...

Regards,

Erik.
0
 
LVL 3

Accepted Solution

by:
sperling earned 400 total points
ID: 1337100
I decided to finish the service skeleton right now. Go have a look at my homepage. http://www.info-pro.no/sperling

Regards,

Erik.
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1337101
Thanks - I'll have a play!
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1337102
Needs more work than I expected.
I think I'll come back to this one later in the year.
A program in the startup folder will do for now.

Thanks.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question