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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:19:33+00:00 2026-05-15T17:19:33+00:00

Private Declare Function GetPrivateProfileString Lib kernel32 Alias _ GetPrivateProfileStringA (ByVal lpApplicationName As String, _

  • 0
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
        "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
            ByVal lpKeyName As String, _
            ByVal lpDefault As String, _
            ByVal lpReturnedString As String, _
            ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Dim value As String = ""
Dim length As Integer
Dim IniFileName As String

GetPrivateProfileString("Config", "UserName", "None", value, length, IniFileName)

but value contains an empty string!?

I confes to being a VB n00b, less than a week, in fact, but I can’t see what’s wrong there. The file exists, it contains a section called “Config” which has an entry called “UserName” with a value – but even if not, wouldn’t value take the default?

(And, no, I don’t want to use the registry, thanks 😉


Edit: It’s not returning an empty string – it’s returning whatever I initialize value to before calling GetPrivateProfileString().

Which is to say that if I

Dim value As String = "xxx"

then it stil contains “xxx” after the call and not the default value.

  • 1 1 Answer
  • 1 View
  • 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-05-15T17:19:33+00:00Added an answer on May 15, 2026 at 5:19 pm

    You have to set the size in the params, and reserve space for the result.
    Insert this lines before the call to the function:

    value = space(255)
    length = len(value)
    

    Forgot something: you have to use the return value of the function, as this is the length of the actual value you get, and use a Left(value,length) to get your real answer.

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

Sidebar

Related Questions

I have Private Declare Function ReadProcessMemory Lib kernel32 Alias ReadProcessMemory (ByVal hProcess As Integer,
VB.NET 2008 Express Private Declare Function CreateWindowEx Lib user32 Alias CreateWindowExA (ByVal dwExStyle As
Private Declare Function CascadeWindowsNative Lib user32 Alias CascadeWindows ( _ ByVal hwndParent As Long,
I have the current code: Public Declare Function FindWindow Lib user32.dll Alias FindWindowA (ByVal
Original Working VB_Code Private Declare Function ConnectReader Lib rfidhid.dll () As Integer Private Declare
Module Module1 Public Declare Function GET_CALCULATION_FAN_ALONE Lib EbmPapstFan.dll (ByRef path As String) As Long
I have the following declaration in a Module: Private Declare Function gzopen Lib ZLIB.DLL
// declare a class with private variable int * _a // declare a function
hello i'm using vb 2008 here is part of my code: Private Declare Function
What is the C# equivalent of this VB code? Private Declare Auto Function InternetSetOption

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.