Results 1 to 3 of 3

Thread: INI file

  1. #1

    Thread Starter
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Unhappy

    Can an INI file have a maximum length ?
    I made 2 ini files. one is only 1 page long, the other is 50 pages long. When I try to read data with the GETPRIVATEPROFILESTRING-api, it returns the correct value from the 1 page long file, but from the 50 pages long file, he returns the default("").

    Code:
    tmpReturn = String$(100,0)
    Default = ""
    'The file with 1 page
    File1 = "C:\myMap\inifile1.ini"
    'The file with 50 pages
    File50 = "C:\myMap\inifile50.ini"
    
    'The strTemp variable will contain the value of "Key"
    strTemp = GetPrivateProfileString("Heading","Key",Default,_
    tmpReturn,Len(tmpReturn),File1)
    
    'The strTemp variable will contain ""
    strTemp = GetPrivateProfileString("Heading","Key",Default,_
    tmpReturn,Len(tmpReturn),File50)
    WP

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

  2. #2
    Guest
    Try reading the 50 pages like this:

    Code:
    Public Function ReadINI(strsection As String, strkey As String, strfullpath As String) As String
       Dim strbuffer As String
       Let strbuffer$ = String$(750, Chr$(0&))
       Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
    End Function
    
    strTemp = ReadINI("Heading","Key",File50)

  3. #3

    Thread Starter
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    difference?

    So you only changed the length of strBuffer$. But my values are max 100 characters long, so...

    WP

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

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