Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to write an NT Service

Posted on 1997-06-16
12
Medium Priority
?
255 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
Independent Software Vendors: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 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