Results 1 to 6 of 6

Thread: Megatron or other GURU error in Ini read

  1. #1
    Jethro
    Guest

    Unhappy Megatron or other GURU error in Ini read

    This is weird?

    Code:
    sSectionName = "Hello Newman"
    sValueName = "Episode"
    sIniDefault = "c:\wherever\seinfield.ini"
    sIniFile = sIniDefault
    Dim lReturnCheck As Long
    Dim sReturnValue as String * 50
    '
    lReturnCheck = GetPrivateProfileString(sSectionName,sValueName,sIniDefault,sReturbValue,Len(sReturnValue),sIniFile)
    '
    If lReturnCheck = 0 Then
      GetIniValue = ""
    Else
      GetIniValue = Trim(sReturnValue)
    End If
    Ok the problem is that even if the ini file does not exist lReturnCheck returns a value of 21 or 22 and sReturnValue has the ini File Name and 10 or so return characters.

    How come lReturnCheck isn't returning 0?

  2. #2
    AIS_DK
    Guest
    GetPrivateProfileString doesn't indicate by it's return value whether it has succeded in retriving the information from the file. It always return the length of the textbuffer, that is the lenght of the text retrieved.
    And since you give a default value, it vil return the default value and the length of the returnvalue.

    Thats it!!!!

    A suggestion might be, to replace the default value with a empty string : "", that way you can detect the error be testing the returned string:
    Code:
    if strReturn = "" then debug.print "ERROR"

  3. #3
    Megatron
    Guest
    It should be returning the number of characters in sIniDefault (this API is not one of those Success/Fail types).

  4. #4
    Jethro
    Guest

    Thumbs up Hey thanks guys

    That was quick, (as my wife is apt to say)

    Good point AIS, will try that out...excellent works !!!!!!!!!!!!!!!!

    Now all l have to do is figure out why on earth l had the "* 50" in the first place?

    Our office net is down, am on site, so expect a heap of questions in the next few days...can never remember the API calls.

    Megatron

    Gorilla???????????????????????

  5. #5
    Megatron
    Guest
    Guerrilla: It's another term for "Rebel"

  6. #6
    Jethro
    Guest

    Thumbs up

    Originally posted by Megatron
    Guerrilla: It's another term for "Rebel"
    ]

    Now l get it. I was thinking in terms of the great Ape, not Che etc.

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