What is the current default service working directive on Windows?

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

+1


a source to share


2 answers


The current working directory is the location of the service executable, unless changed with a win32 API call SetCurrentDirectory



+2


a source


The call GetCurrentDirectory

to the service entry point returns "C: \ WINDOWS \ system32". After installing it in the executable directory, SetCurrentDirectory

everything worked as expected.



+1


a source







All Articles