在Visual C++ 7.0中,设置相对路径的时候,需要注意的地方在于,如果相对路径设置的位置在Cpp或者头文件中,那么它对应的当前路径是这个文件的路径。比如:工程文件Test.vcproj在b:Test中,而源文件是在b:TestScr中,那么源文件的相对路径的起始路径就是b:TestScr,不是b:Test。

  在这里说的,是一种特殊情况下发现的。是某个类库,通过头文件来确定选择使用什么类库,相对路径是在编译期使用的,才是这个样子。否则,如果在运行时使用相对路径,那么应该就是当按F5调试的时候,以工程文件所在目录作为起始目录,在实际运行时候,以运行的可执行文件所在目录作为起始目录。如果编译出来的是一个动态链接库,我还不知道。

In Visual C++ 7.0, when you want to set a relative path, you should notice that if the relative path is setted in the source file or the header file, the start path is the folder which the source file or the header file located in. For example, the project file Test.vcproj is in the folder of b:Test, and the source files are all in b:TestSrc, then relative path is start from b:TestScr, not b:Test. If you want to visit the project file in the source file, you should write ..Test.vcproj, not .Test.vcproj.

But this is not a common regular, this is under a speical situation: a Class Library, which decide use Unicode Edition or ANSI Edition by header files. The relative path is used Compile-Time, not Run-Time. If the relative path is used Run-Time, if you press F5 to debug the project in Visual C++, the start folder is the folder where the project file is located in, if you run it as a executable file, the start folder is the folder where the executable file located in. But if it is a dll file, I don’t know.

原文来自我的教育网博客