c++,如何在代码中获取解决方案目录

c++, how to Get the solution directory in the code

我正在为 returns 其完整路径的 dll 函数编写单元测试。 测试项目和dll项目都在同一个解决方案中。

我正在考虑获取解决方案目录并将其余路径附加到断言。

在测试项目的预处理器定义中定义:_SOLUTIONDIR=$(SolutionDir);

但在测试文件中我得到 #define _SOLUTIONDIR C:\*\Project\ expands to C:\*\Project\ unrecognized token

我应该如何将其转换或转换为字符串?或者一般来说,获取相对路径的最佳方式是什么?

dll file has function returning 
--------------------------------
 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
LPTSTR  strDLLPath1 = new TCHAR[_MAX_PATH];
        ::GetModuleFileName((HINSTANCE)&__ImageBase, strDLLPath1, _MAX_PATH);
        wstring temp1(strDLLPath1);
        string temp2(temp1.begin(), temp1.end());
return temp2;

解决方案是定义_SOLUTIONDIR如下

_SOLUTIONDIR=R"($(SolutionDir))"