如何使用GetPrivateProfilestring()从当前目录上升级目录
How to go up a directory from current directory with GetPrivateProfileString()
我正在尝试使用 GetPrivateProfileString
从INI文件中读取我的程序的身份详细信息。我想上directory/Folder/File.ini
(,但不知道该怎么做
我尝试了GetFullPathName()
void ini {
std::string iniPath = "/Ice/Ice.ini";
LPWSTR inipath = A2W_EX(iniPath.c_str(), iniPath.length());
DWORD IniPath = std::strtoul(iniPath.c_str(), NULL, 16);
std::string playerUsername;
std::string playerPassword;
TCHAR iniauthChar[32];
playerUsername = GetPrivateProfileString(authheader, authuser, 0, iniauthChar, 256, inipath);
playerPassword = GetPrivateProfileString(authheader, authpass, 0, iniauthChar, 256, inipath);
}
这是我的INI文件,位于上方的目录
上方[AUTH]
Username=
Password=
您应该使用\
而不是/
用于Windows上的目录路径。
#include <windows.h>
#include <iostream>
int main()
{
LPWSTR fn = L"Ice\Ice.ini";
wchar_t buf[MAX_PATH];
GetFullPathNameW(fn, MAX_PATH, buf, NULL);
std::wcout << buf << std::endl;
}
或ANSI字符串:
#include <windows.h>
#include <iostream>
int main()
{
LPSTR fn = "Ice\Ice.ini";
char buf[MAX_PATH];
GetFullPathNameA(fn, MAX_PATH, buf, NULL);
std::cout << buf << std::endl;
}
相关文章:
- 如何在不同目录中使用制作文件中的文件
- 为什么这不会在当前目录中生成文件?
- 下载到当前目录
- 如何使用GetPrivateProfilestring()从当前目录上升级目录
- g++ 不会先搜索当前目录中的标头
- 在同一目录中使用conanfile.txt和conanfile.py
- 如何使用<windows.h获取当前目录名称> C++
- 使用.cpp使用G 在同一目录上使用.CPP,错误
- 如何使肮脏忽略当前目录
- 如何将文件写入当前目录而不是Bazel-Out
- 列出当前过程并使用未记录的当前功能编写内存的软件技巧
- GetPrivateprofilestring 不会获取当前目录中的 ini 文件
- 在我的工作目录中使用 glfw -3.2.1,如何使用 makefile 使用它进行编译
- 无法写入可执行对象的当前目录中的文件夹
- C - 如何获得C 可执行文件的当前目录
- 电话目录程序使用C 中的2D数组
- 获取当前目录,我可以在不知道最大缓冲区大小的情况下进行
- 仅在当前目录中搜索标签
- 如何在当前目录中强制使用dll文件
- 使用ifstream和QtCreator从当前目录中读取文件