Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ini file size limit? (VBA Office2K)

    Is anyone aware of a limit on the size of an .ini file?

    I have one that keeps getting truncated while reading from
    the file using PrivateProfileString.

    The truncated file is 64K? Is that the limit?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ini file size limit? (VBA Office2K)

    If I remember well, 64k is the limit of a Notepad file.
    If PrivateProfileString use Notepad in one or other way to access the .ini file ....

    The only other method i can think is a sequential reading of the file and analyse the line to find what your looking for.
    <pre>Dim TextLine
    Open "TESTFILE" For Input As #1 ' Open file.
    Do While Not EOF(1) ' Loop until end of file.
    Line Input #1, TextLine ' Read line into variable.
    Debug.Print TextLine ' Print to the Immediate window.
    Loop
    Close #1 ' Close file.</pre>

    Hope this help
    Francois

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ini file size limit? (VBA Office2K)

    I'd add that I've seen it recommended to use XML documents instead of ini files. You'll need to reference the MSXML parser in your project. <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ini file size limit? (VBA Office2K)

    I doubt that there's any limit.
    If you search your drives, you will find .ini files much larger than 64K included with some apps.

    Of course, that does not mean that VBA doesn't have a bug, i.e., some poor programmer may have included a 64K buffer WITHIN VBA.

    If you can reproduce this with a simple example in VBA, I'd suggest trying the identical code in VB 6.

    If you don't have VB 6, then export the VBA module to a .bas file. And create a .zip with the .bas .ini file. Email me the .zip and I'll try it in VB 6.

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: ini file size limit? (VBA Office2K)

    I don't know for sure, but it seems much more likely that the limitation relates to the PrivateProfileString property, rather than the .ini file itself.

    At least based on the code samples in VBA Help and at the MS KB site, PrivateProfileString is designed for reading key values in sections of .ini files, rather than the entire file itself.

    Although I can't speak from experience of having used it, it looks like the ReadAll method of the TextStream object (which is part of the FileSystemObject) might work to get around the size limitation.

    Gary

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ini file size limit? (VBA Office2K)

    The implication of the poster's question would seem to be:

    1. PrivateProfileString is being used to read the stuff in a .ini. PrivateProfileString doesn't read a file, just the individual name/value pairs.

    2. The .ini file is more than 64KB.

    Neither of the above should cause any problem.

    If there is a problem, I would expect:

    1. A bug in the implementation of PrivateProfileString, which I doubt, at least as far as accessing individual elements of a .ini.

    2. A botch in the implemenation of PrivateProfileString if a particular element happens to be more than 64KB bytes. Implementors sometimes do silly things such as ASSuME-ing what users "need", rather than making the code more general, which is often faster and easier anyway.

    My offer to look at the .ini still stands, but expires at midnight today Eastern Standard Time in the USA.

  7. #7
    Star Lounger
    Join Date
    Aug 2001
    Location
    GA
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ini file size limit? (VBA Office2K)

    The problem is NOT with the size of the INI file itself.

    When using PrivateProfileString to read and write to an INI file the following limitations apply.
    1. The Windows API imposes a limit of 64KB on INI files. (it's a Win3.X hold over issue)
    2. The text for each Key Value entry must be under 256 bytes.

    If you exceed the limits; for 'Reads', data beyond will be ignored and for 'Writes' data will be truncated.

    Your choices:
    1.You'll have to write your own functions If you want similar read/write/create Key Value functionality of the PrivateprofileString for INI files larger than 64KB.
    2. Rethink what you are doing and find a better what to deal with the chunk of data your storing.
    3. Use the Windows Registry (don't be scared... do it)
    4. Try splitting the INI info into several logical groups of KeyValues thereby having several smaller INI files.
    i.e. UserSettings.INI myAppSystem.INI Security.INI OtherStuff.INI

    Ohhh, and a side note. Not related to the 64KB+ problem but about using the PrivateProfileString API call in general. Be sure you pass everthing to the API using "ByVal". Newbies cutting and pasting examples from the Web can get caught by examples that do not include the "ByVal" for variables passed to the API. Even older Microsoft Help Files had this error in their example of using PrivateProfileString API calls.

    Later,
    Bruce

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ini file size limit? (VBA Office2K)

    Re the 64K limit and reference4s to 256-byte key values.

    A few months ago i re-wrote my INI routines to handle values longer than 256bytes. I can dig those out if you are interested.; I suspect that the ones posted here (a few months ago) are out of date.

Posting Permissions

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