Solved

Reading INI file

Posted on 2015-01-07
6
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 9

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 34

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 34

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

735 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