Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
SQL
D:\User\Desktop\Nos Backup

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


C++
// 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^ ?
Posted
Updated 13-Sep-14 12:32pm
v2

1 solution

The problem is the single byte char array.

Change to
C++
wchar_t retStr[255] = L"";
 
Share this answer
 
Comments
IceTrailer 13-Sep-14 13:28pm    
Thanks, this fixes my problem!
George Jonsson 13-Sep-14 13:34pm    
You're welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900