|
-
Jul 31st, 2006, 05:41 AM
#1
Thread Starter
Member
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.
-
Jul 31st, 2006, 06:52 AM
#2
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.
-
Jul 31st, 2006, 01:39 PM
#3
Re: ini size problems
Try
VB Code:
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.
-
Jul 31st, 2006, 01:49 PM
#4
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.
-
Aug 22nd, 2006, 01:46 PM
#5
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|