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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetCurrentDir in a NT Service App

Status
Not open for further replies.

DanielRoca

Programmer
Nov 24, 2008
2
BO
Hi, I'm programing a small NT Service app in Delphi 7, and I need to load an ini file in order to get some parameters, when I do for example:

ConfigIni:= TIniFile.Create('C:\Config.ini');

an obviously put the ini file in that path every thing works fine, but I would like to get the ini file not from a fixed path in the code but from the same path where the myservice.exe es located, to do that I've try two metods that work fine in a normal app but for some reason do not in the service

ConfigIni:= TIniFile.Create(ExpandFileName('Config.ini'));
or
ConfigIni:= TIniFile.Create(GetCurrentDir+'Config.ini');

any ideas why is this happening and of course how can I make this work.

Thanks.
 
query the registry key :
'\SYSTEM\CurrentControlSet\Services\'+<the name of your service>, look for the Imagepath string Value

/Daddy


-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I've always found ExtractFilePath(ParamStr(0)) to work fine, even in service applications.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top