GetPrivateProfileString只返回第一个字母,该怎么办? [英] GetPrivateProfileString returns only the first letter, what to do?

查看:65
本文介绍了GetPrivateProfileString只返回第一个字母,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,在正确使用GetPrivateProfileString函数后,我遇到了问题。 lpReturnedString应该是一个路径,但只返回C或D(取决于磁盘字母)



但路径应该看起来像

 D :\ User \Desktop \Nos 备份 



以下是代码,我希望得到一些帮助。





  //  顶部的一些不相关的代码 

char retStr [ 255 ];

GetPrivateProfileString(cstrSec,cstrKey1,cstrDef,(LPTSTR)retStr, 255 ,cstrIni);
tbNostaleDataPath-> Text = gcnew System :: String (retStr);







有什么问题?也许从char []转换为LPTSTR然后再转回System :: String ^?

解决方案

问题是单字节 char 数组。



更改为

  wchar_t  retStr [ 255 ] = L  ; 


Hello guys, after using the GetPrivateProfileString function correctly, I got a problem. the lpReturnedString should be a path, but only returns C or D (depending on disk letter)

But the path should look like

D:\User\Desktop\Nos Backup


Following is the code and I hope to get some help.


// Some irrelevant code on the top

char retStr[255];

GetPrivateProfileString(cstrSec, cstrKey1, cstrDef, (LPTSTR)retStr, 255, cstrIni);
tbNostaleDataPath->Text = gcnew System::String(retStr);




What is wrong? Maybe the conversion from char[] to LPTSTR and then back to System::String^ ?

解决方案

The problem is the single byte char array.

Change to

wchar_t retStr[255] = L"";


这篇关于GetPrivateProfileString只返回第一个字母,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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