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 56805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:35:31+00:00 2026-05-10T17:35:31+00:00

I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from .NET

  • 0

I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from .NET and came across something odd I don’t understand.

Let’s start with this encantation:

    Private Declare Unicode Function GetPrivateProfileString Lib 'kernel32' Alias 'GetPrivateProfileStringW' ( _     ByVal lpApplicationName As String, _     ByVal lpKeyName As String, _     ByVal lpDefault As String, _     ByVal lpReturnedString() As Char, _     ByVal nSize As Int32, _     ByVal lpFileName As String) As Int32 

If I pass an lpApplicationName (section), no lpKeyName and no lpDefault, I should get all of the keys for that section, and indeed I do: 50% of the time.

If the ini file has the lpApplicationName starting on the first line, the buffer returns nothing. If lpApplicationName stats on the second line in the file, it returns the expected values.

At first I though it was a matter of using the W version and Unicode in the Declare, but changing those seems to have no effect.

What am I missing?

  • 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. 2026-05-10T17:35:32+00:00Added an answer on May 10, 2026 at 5:35 pm

    Check to see if the file you are opening has a byte order mark (a few bytes marking the type of text encoding).

    These Windows API calls don’t seem to grok byte order marks and is causes them to miss the first section (hence everything works fine if there is a blank line).

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

Sidebar

Related Questions

I'm a PHP guy learning some .NET. I am tinkering around with the UpdatePanel
Just trying to download it from http://www.asp.net/downloads for the first time. Web Platform Installer
Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me.
just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview
I've been tinkering around with Flex RemoteObjects, and I've found that they aren't very
I've been tinkering around with Zend-Framework and Jquery for a month or so, and
INITIAL NOTE: This is just for a personal tinkering project; I'm not writing enterprise
I started tinkering around with HTML5 recently and am very interested in Audio tag.
Just getting started with iphone and ipad apps. Lots of reading, lots of tinkering,
I'v been tinkering with Live Wallpapers today and wouldn't you know it, I just

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.