c ++ GetPrivateProfileString从当前目录读取ini文件

Nur*_*yev 8 c++ ini visual-studio

我在c ++上创建一个dll.它是一个Visual Studio项目.dll从ini文件中读取一些数据.我决定使用GetPrivateProfileString函数.它几乎完全有效.它没有在当前目录中看到文件.如何提供此参数(称为路径的变量)?

如何传递最后一个参数(路径)

码:

LPCTSTR path = L"\\test.ini";
TCHAR protocolChar[32];
int a = GetPrivateProfileString(_T("Connection"), _T("Protocol"), _T(""), protocolChar, 32, path);
Run Code Online (Sandbox Code Playgroud)

test.ini中的字符串:

[Connection]
Protocol = HTTP
Run Code Online (Sandbox Code Playgroud)

我也试过这个:

LPCTSTR path = L"test.ini";
Run Code Online (Sandbox Code Playgroud)

但它没有帮助我

Had*_*deS 14

LPCTSTR path = _T(".\\test.ini");
Run Code Online (Sandbox Code Playgroud)

.象征当前目录.希望这对你有用.