programming a service

G

Guest

I am using MS Visual studio 2003 C++
I am tring to program my first service and am having many questions and
issues.
1) Is there any documentation/ book that has good examples with details on
how decsions where made in selecting various service options.

2)I would like to create a log file, but when I use LocalService as an
account I don't have permission to open files. I was able to open files when
set account to LocalSystem, but this seems overkill and maybe to permissive.

3) I need to be able to open an .ini file which I believe I will have in the
directory where service executable gets installed. The service seems to know
what directory this is, but I can't figure out how to get directory
information so that I can open the file. if I use the _getcwd command it
returns the C:\windows\system32 directory. I don't want to have to hardcode
this information in program, since it may be installed in different
directories

4) I will be using ADO.net to access a remote oracle database so I don't
know if this has any bearings on how I set up the service, especially the
account.

In General my service is going to be reading input from a card reader that
is on the local PC and place the data in a remote oracle database. So any
suggestions on how to procceed learning what I need to know to do this would
be appreciated. I am planning to have 1 thread read data from unit on PC and
another thread to place data into database using ADO.net. I am not very
familiar with .net programming but have gone through microsofts visual C++
..NET step by step book for version 2003.
 
D

doug mansell

brian_harris said:
I am using MS Visual studio 2003 C++
I am tring to program my first service and am having many questions and
issues.

First suggestion would be to develop and debug your service as a regular
application. Then turn it into a service and sort out all the
permissions problems. :)
1) Is there any documentation/ book that has good examples with details on
how decsions where made in selecting various service options.

Lots of stuff in msdn.

2)I would like to create a log file, but when I use LocalService as an
account I don't have permission to open files. I was able to open files when
set account to LocalSystem, but this seems overkill and maybe to permissive.

Try locating the log file in c:\windows\temp\ and see if you still have
problems creating it.

3) I need to be able to open an .ini file which I believe I will have in the
directory where service executable gets installed. The service seems to know
what directory this is, but I can't figure out how to get directory
information so that I can open the file. if I use the _getcwd command it
returns the C:\windows\system32 directory. I don't want to have to hardcode
this information in program, since it may be installed in different
directories

You can store the ini filename in the registry, setting it up at install
time. Or use call the win32 api GetModuleFileName to find the path of
the exe.
4) I will be using ADO.net to access a remote oracle database so I don't
know if this has any bearings on how I set up the service, especially the
account.

Should be right... :)
In General my service is going to be reading input from a card reader that
is on the local PC and place the data in a remote oracle database.

In my experience, card readers are a bit of a nightmare... so good luck.
So any
suggestions on how to procceed learning what I need to know to do this would
be appreciated. I am planning to have 1 thread read data from unit on PC and
another thread to place data into database using ADO.net. I am not very
familiar with .net programming but have gone through microsofts visual C++
.NET step by step book for version 2003.

Oh... so you're actually developing a .net app not a native app? Do it
in c# then. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top