Results 1 to 4 of 4

Thread: retrieve from ini with getprivateprofilestring

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Posts
    205
    I am having trouble retrieving from an ini. I only get a blank string. Any help would be appreciated!

    Here's my code:

    Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

    buffer = String(145, " ")
    rc = GetPrivateProfileString("test", "test", "default", buffer, Len(buffer) - 1, "D:\test.ini")
    retstring = Left(buffer, InStr(buffer, " ") - 1)

  2. #2
    Tygur
    Guest
    Change this line:
    retstring = Left(buffer, InStr(buffer, " ") - 1)

    to this line:
    retstring = Left(buffer, InStr(buffer, Chr(0)) - 1)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Posts
    205

    Unhappy

    That's how I started. I get an "invalid procedure call or argument" error on that line when it runs. Any other ideas?

  4. #4
    Tygur
    Guest
    Make sure you declared buffer as a string:
    Dim buffer As String

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width