look at this tutorial; maybe that will help clarify things
http://finn.mobilixnet.dk/
good luck
Ed
Main Topics
Browse All Topicshi
I'm trying to write a windows service and I am having trouble just writing a log file!
the code I'm using works fine in a normal delphi app, but if I put it in the service code, delphi beeps when I try to start the service and the service won't start. If I put the code in the service thread procedures, the service starts but doesn't write to the log file.
what am I doing wrong? are there things you just can't do with a service?, or is there a trick I need to know?
what else am I going to have problems doing in a service?! Is there a resource anywhere I can get more information on tricks to programming services?
thanks
Bob
code is
var
LogFile : textfile;
.
.
AssignFile(LogFile,'nbidus
Rewrite(LogFile);
writeln(LogFile,'starting up');
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
look at this tutorial; maybe that will help clarify things
http://finn.mobilixnet.dk/
good luck
Ed
Business Accounts
Answer for Membership
by: ciulyPosted on 2007-02-11 at 04:34:42ID: 18509955
the service will by default be started as the local system account/user. also, the working directory is %SYSTEM% (c:\windows\system32\ on most systems). so what you need to do is create a directory for the log file where the local system account has access right to write to.
TrailingPa thDelimite r(GetEnvir onmentVari able('temp '))+'nbidu s.log');
usually this is done from the program installer: it will install for ex in program files\my app and create a directory named "logs" or whatever you wnat, and add the service user (local system account by default) to that directories ACL with write access.
for youir conveniece, just to see that the service starts up and write to the log file do like this:
AssignFile(LogFile,Include
Rewrite(LogFile);
writeln(LogFile,'starting up');
this will put the log file in the %TEMP% directory (from the local system account's environment, not yours).
on my machine I have set the temp variable to c:\temp and everybody has full acces to it. this way I don't get lost in the multiple temp directories from the system :)