您的位置:首页 > 其它

无语了, windows 中的字符转换

2016-11-07 17:15 302 查看
LPCWSTR strName = L"shuishi张三";

LPCWSTR appName = L"StudnetInfo";

//判断文件夹是否存在
int state = _access( File_Path, ABI::Windows::Devices::Custom::IOControlAccessMode::IOControlAccessMode_Any);
//Windows::Devices::Custom::
bool isFileExist;
if (state != 0)
{
//不存在这个文件夹, 需要重新创建文件夹
int dirSuccess = mkdir(File_Path);
if (dirSuccess != 0)
{
assert(false, "the dir can't create");
}
}
else
{
//直接读取即可
}

//拼接字符串
char strFile[1024];
sprintf(strFile, "%s\\%s", File_Path, File_Name);

LPCWSTR convStr = (LPCWSTR)strFile;

std::ofstream fout(strFile);
if (fout)
{
std::cout << "创建成功" << std::endl;
std::cout << File_Path << std::endl;
}
else
{
std::cout << "创建失败" << std::endl;
std::cout << File_Path << std::endl;
}

LPSTR lpStr = (LPSTR)(LPCSTR)(strFile);

LPCWSTR lpCW = A2WBSTR(lpStr);

int ptr = WritePrivateProfileString(L"StudnetInfo", L"Name", strName, lpCW);

看来还需要多学习啊, windows 中的字符及编码还是没太摸清楚
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: