views:

21

answers:

3

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.

A: 

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.

Mark
A: 

Why not just use a build event that moves or copies the executable to the root? If you are personally against build events (perhaps MSBuild does not account for them in your build system?), then use the build system itself (such as msbuild) to make a target that copies / moves the executable.

Brent Arias
A: 

Just set the path to include the desired directory. The application will use the path to find your dlls.

Mike