views:

150

answers:

2

I'm adapting a program to run as a service, and the first thing it does is open a local configuration file, but it doesn't exist because I don't know what is the current directory.

+3  A: 

The current working directory is the location of the executable of the service, unless modified using the win32 API call SetCurrentDirectory

Adam
A: 

Calling GetCurrentDirectory at the service entry point returns "C:\WINDOWS\system32". After setting it to the executable's directory with SetCurrentDirectory everything worked as expected.

But, why the system is setting current directoy to windows\system32 initially .. ??
Vadi