Search code examples
visual-c++dllworking-directory

Change program's working directory in compile-time in Visual C++


Is there a way to define a program's working directory to be different from its current directory at compile-time, on Visual C++? The bosses want the executable to be on the root directory but all DLLs to be in a separate dir.


Solution

  • You can use the SetCurrentDirectory Win32 API to change the working directory at runtime, but there's nothing that should be (nor could be) done at compile-time other than hard-code some path and use the same API call.