Results 1 to 5 of 5

Thread: ini size problems

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    54

    ini size problems

    Im using the ini API's in my project.

    Call GetPrivateProfileSection(name, szBuf, 255, App.Path & "\Profile.ini")

    Each section has 8 parts, holding 4 characters of information, which is an ID number for a database.
    [Science Block]
    0200
    0210
    0200 etc

    As I havent found a way to delete sections from the ini, I mark them as void when the user wishes to delete them:-
    [Science Block]
    VOID
    0200
    0210 etc
    so they aren't added to the list box for the user to select.

    The problem is there end up a lot of info in the ini file, most not needed.
    Some sections aren't being read, as the VOID sections are still read into the buffer.
    How big can I safely make the buffer, or is there a better way of going about this?

    Thanks.

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: ini size problems

    Well what you can do to remove all these VOID's is to open the inifile and read each line of the file. Use the Instr function to check if VOID is present if not then add this line to a ListBox. After you have read the file you can save it by writing the contents of the ListBox back to the inifile. So everything in the ListBox shouldn't contain VOID.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: ini size problems

    Try
    VB Code:
    1. Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
    Use "" for the section string and it should delete the whole section.

  4. #4
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: ini size problems

    Yes that will delete the value but it will still leave the Key behind.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    54

    Re: ini size problems

    Hi Guys, sorry so long in answering but I have been on holiday.

    In the end I had to dump the ini files API.

    Keithuk is right, couldn't delete all I wanted using API's.

    I used .txt files, just copied all info except the "deleted" section to a new .txt file, deleted the old file and renamed the new .txt

    Works great, I'm just a little frustrated I couldn't use an API to delete the key and the key contents.

    Thanks for your help though

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