Solved

Reading INI file

Posted on 2015-01-07
6
232 Views
Last Modified: 2015-01-08
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?????
0
Comment
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Subrat (C++ windows/Linux)
ID: 40537302
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
 

Author Comment

by:Santhamohan Manivannan
ID: 40537306
So, we need to change settings in Project properties.....
0
 
LVL 33

Accepted Solution

by:
sarabande earned 500 total points
ID: 40537341
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Closing Comment

by:Santhamohan Manivannan
ID: 40537530
Thank you so much Guys!!!! It really worked out!!!!!!!!!!!!!!!
0
 

Author Comment

by:Santhamohan Manivannan
ID: 40537576
Can I do the same thing for the String also????
0
 
LVL 33

Expert Comment

by:sarabande
ID: 40537676
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now