Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:45:38+00:00 2026-06-07T18:45:38+00:00

I am writing some properties in a ini file using WritePrivateProfileString function and everything

  • 0

I am writing some properties in a ini file using WritePrivateProfileString function and everything works fine but when I add text with multiple lines, there is a problem.

Here is the code and output.

WritePrivateProfileString(_T("General"), _T("Name"), OLE2CT(text), FilePath);

Output:

[General]
Name=mytext

.

text = address\nstreet\nhouse
WritePrivateProfileString(_T("General"), _T("Address"), OLE2CT(text), FilePath);

Output:

[General]
Name=mytext
Address=address
street
house

But when after adding a multiple line item, i add another item, instead of adding this to end it adds new line just after Address line

text = city
WritePrivateProfileString(_T("General"), _T("City"), OLE2CT(text), FilePath);

Output:

[General]
Name=mytext
Address=address
City=city
street
house

but the output should be

[General]
Name=mytext
Address=address
street
house
City=city

What is problem with my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:45:42+00:00Added an answer on June 7, 2026 at 6:45 pm

    I strongly recommend you read up on your problems on Michael Kaplan’s blog.

    If you absolutely have to use INI files, don’t use the deprecated Win32 API functions you are using right now. They are buggy and bugs sure won’t get fixed anymore as they are deprecated by now.

    Instead use SimpleIni a very decent cross-platform implementation of an INI reader/writer for C++.

    Microsoft (as a whole) seems to be unsure whether they prefer registry or other mechanisms for storing configuration data. At some point it was INI files, then it was the registry (to me a superior mechanism) and then it seemed to shift towards XML and other file-based storage mechanisms. It’s certainly your use-case that will define what you need, but consider all the words of caution about using these deprecated functions and look at least for an alternative mechanism of working with INI file if you have to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am writing some junit tests, using an EJBContainer. All works fine, except getting
I'm writing out some xml from C# using the .net framework's XmlTextWriter. This works
So I was writing some queries today and was using top 10 on a
I'm using Expression Blend 3 and am writing some of the XAML by hand,
I am writing an XML file in C# using XmlWriter. I am able to
Though java.util.properties allows reading and writing properties file, the writing does not preserve the
I have been writing some code that detects add and removal of USB devices,
I'm writing some code for a class constructor which loops through all the properties
I'm using Spring 3.1.0.M2. I'm writing some JUnit 4 tests to test some database
I'm writing a Custom ContentPipeline and I've added some Normal and Specular Map properties.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.