Reading INI file

I am using this code for taking values from INI files,

"int vers = GetPrivateProfileInt(L"VERSION", L"Version", -1, L"E:/KTDaemon/Data/INI/KTDaemon.ini");"

I've tried lot, but this one worked by prefixing 'L' on String.Is there any replacements?????
Santhamohan ManivannanSoftware EngineerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sarabandeConnect With a Mentor Commented:
So, we need to change settings in Project properties.....
if you don't need Unicode support, yes.

if you need Unicode (or better Microsoft UTF16) you have two choices.

either call

"int vers = GetPrivateProfileIntA("VERSION", "Version", -1, "E:\\KTDaemon\\Data\\INI\\KTDaemon.ini");"

or

you have to write (and create) the inifile using SetPrivateProfileInt with a program or function where also UNICODE was switched on.

Sara
0
 
Subrat (C++ windows/Linux)Software EngineerCommented:
Your character is UNICODE. So you have to use L or _T().
If in project setting you are using 'multi byte char set',  instead of 'Unicode Char', then it will work without L
Let us know if you need more information!!!
0
 
Santhamohan ManivannanSoftware EngineerAuthor Commented:
So, we need to change settings in Project properties.....
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Santhamohan ManivannanSoftware EngineerAuthor Commented:
Thank you so much Guys!!!! It really worked out!!!!!!!!!!!!!!!
0
 
Santhamohan ManivannanSoftware EngineerAuthor Commented:
Can I do the same thing for the String also????
0
 
sarabandeCommented:
you should give assist points to subrat for his valid comment. you could reopen the question by using the 'Request Attention' button below your original question.

Can I do the same thing for the String also????
I assume you mean to read strings from ini file:

char szResult[256] = { '\0' };
DWORD ret = GetPrivateProfileStringA(("VERSION", "ProductName", "not provided", szResult, sizeof(szResult),
                                         "E:\\KTDaemon\\Data\\INI\\KTDaemon.ini");"

Open in new window


Sara
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.