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
Solved

Reading INI file

Posted on 2015-01-07
6
245 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 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 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

808 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