Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program as a service

Status
Not open for further replies.

jamescpp

IS-IT--Management
Aug 29, 2001
70
US
I have a program that is now working correctly when I run it from a command prompt on NT. I installed the program as a service using srvany.exe. Now it doesn't work.

Problem is that I have to hard code file locations that the program uses. For example, I read a file for some parameters and the program bombs unless I hardcode the location of the file. How do you deal with this type of situation? I need the program to run as a service.

I also open and write to a log file. Now I could store that location in the ini file, but currently it has the same problem.

Thanks,
James
 
write the path to it in windows registry. When the program wants to find the path, it just should read it from the registry.
You can write it for example under
HKEY_LOCAL_MACHINE\Software\yourprogram
where yourprogram is a subkey what you added.
Put in this subkey a variable, for example path and as value the path to your program, or put the directory of your program as default valye of the key
HKEY_LOCAL_MACHINE\Software\yourprogram Ion Filipski
1c.bmp


filipski@excite.com
 
Ion,

Thanks, got this working with the registry key AppDirectory under the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\myappname\Parameters

Now the problem I have is that the function that Charles suggested, GetPrivateProfileString(), seems to want the full path to the INI file. Otherwise that function works great.

Thanks,
James
 
that ones family functions are available only from MFC. Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top