C ++ GetPrivateProfileString从当前目录读取ini文件 [英] c++ GetPrivateProfileString read ini file from current directory

查看:155
本文介绍了C ++ GetPrivateProfileString从当前目录读取ini文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm creating a dll on c++. It is a Visual Studio project. The dll reads some data from ini file. I have decided to use GetPrivateProfileString function. It works almost completely. It does not see file in current directory. How can I provide this parameter (variable called path)?

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

How can I pass last parameter (path)

代码:

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

test.ini中的字符串:

String from test.ini:

[Connection]
Protocol = HTTP

我也尝试过:

LPCTSTR path = L"test.ini";

但这对我没有帮助

推荐答案

LPCTSTR path = _T(".\\test.ini");

.表示当前目录.希望这对您有用.

. symbolises current directory. Hope this will work for you.

这篇关于C ++ GetPrivateProfileString从当前目录读取ini文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆