【发布时间】:2020-06-13 14:17:02
【问题描述】:
我有个小问题,谁能帮帮我? 问题是““const char *”类型的参数与“LPCWSTR”类型的参数不兼容”
我觉得这样不行,"return (bool)CreateDirectory(path.c_str(), NULL)"
,但我无法意识到,“路径”引用的程序是为了什么。
非常感谢!
代码:
#ifndef IO_H
#define IO_H
#include <string>
#include <cstdlib>
#include <fstream>
namespace IO
{
std::string GetOurPath(const bool append_seperator = false)
{
std::string appdata_dir(getenv("APPDATA"));
std::string full = appdata_dir + "\\Microsoft\\CLR";
return full + (append_seperator ? "\\" : "");
}
bool MkOneDr(std::string path)
{
return (bool)CreateDirectory(path.c_str(), NULL) ||
GetLastError() == ERROR_ALREADY_EXISTS;
}
}
#endif
【问题讨论】:
-
使用 std::wstring 因为您使用的是宽字符。
LPCWSTR是一个宽字符串。 -
@drescherjm ↓↓↓↓↓↓↓↓↓↓↓↓↓