• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

How can i make a ini component to accept ini files larger than 64kb (I like the speed of ini files)

I am using the iniinspector component by greatis
and it doesnt support files larger than 64kb

anyone know of a component that does support larger than 64kb

  • 3
  • 2
  • 2
  • +1
3 Solutions
TMemIniFile doesn't have this limit if I remember correctly.  But it's a replacement for TIniFile itself, you seem to be looking for a component that uses ini files...
Wim ten BrinkSelf-employed developerCommented:
When you're dealing with INI files bigger than 64 KB then you're basically using the wrong file format for your data. You might consider using either a database or an XML file instead. Problem is, the limitation isn't caused by the component but by the Windows API which just refuses to accept INI files this big. INI files are generally just meant to store simple configuration data. Anything that causes them to grow over 64 KB should be a reason to reconsider the design of your application.

Btw, XML is just as fast as INI files if used properly. (With e.g. the MSXML library.)
TheRealLokiSenior DeveloperCommented:
You can make your own routine for reading the ini file.
If all you need to do is *Read* from an ini file, you can do that with some simple code.
If you need to *Write* to the ini file also, then that's a bit more work...
How many things need to talk to the ini file at the same time?
How fast does the ini file access need to be?
How big do you expect the ini file to be? (expected maximum size)
XML would be a very good alternative, let us know if this is an option
Please answer these questions, and someone here will certainly be able to recommend a solution for you
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Alpha_AIAuthor Commented:
Ive done a quick search and it says that XML is very fast alternative.
I would like to try the XML way however I still need a component that allows me to view the XML file (ini file)
How do I get started.

Wim ten BrinkSelf-employed developerCommented:
The more recent versions of Delphi already have some built-in components to use with XML. On the "Internet" component tab you'll find the XMLDocument which provides some simplified interface. With File/New you can also create an "XML Data Binding" unit which converts an XSM file or schema to an easy-to-use (but not 100% compatible) set of components. If your Delphi application is the only tool you use to process the data in your XML file then it's just perfect for what you need.

Your XML file could look a bit like this:

<?xml version="1.0" encoding="UTF-8"?>
  <Section name="Section1">
    <Key name="SomeKeyName1">SomeValue</Key>
    <Key name="SomeKeyName2">SomeValue</Key>
    <Key name="SomeKeyName3">SomeValue</Key>
    <Key name="SomeKeyName4">SomeValue</Key>
  <Section name="Section2">
    <Key name="SomeKeyName5">SomeValue</Key>
    <Key name="SomeKeyName6">SomeValue</Key>

And as you see, it's quite easy to read, too. :-)

At http://xmlspy.com you can find a very good XML editor which can also help you to create XML schema's if you feel up to doing some more complex things. :-) There used to be a free home edition of XMLSpy but I can't find it on their site anymore. Still, it's a good product if you ever start doing more complex things in XML.

If you feel up for a challenge then import the following two type libraries into Delphi:

These two will give you direct access to the MSXML functions but it will take a while before you've learned enough of them to use them comfortably in your code. For beginners, the XML Data Binding that Delphi offers is a lot easier... :-)

Btw, there are quite a few Delphi components that can parse XML files and process them. In the past I've evaluated several of them and if you want speed then use only those components that wrap around the MSXML type libraries. I've seen quite a few XML components where it was Delphi doing the parsing of the XML and that's just too slow. (And not all of those XML components support XML completely.)
Alpha_AIAuthor Commented:
Actually I found that the IniFiles32.pas actually supports more than 64kb. I replaced the IniFiles.pas with IniFiles32.pas and it works fine. My greatis iniinspector works fine
I find ini files much easier to use so no one was able to answer the question that I gave.

However Workshop alex did answer my new request. Since I have the answer I was originally looking for
could you tell me how to collaspe all of these nodes.
hold up, my computer is frozen
Wim ten BrinkSelf-employed developerCommented:
Holding up now... :-)

Collapsing nodes? With XMLSpy? I think it depends on the version you use. The Professional version has the option to collapse the XML and to display it in some grid format.

Anyway, about INI files... In the past I also used to think that INI files are great tools for storing information but XML tends to add a bit more power to your configuration data. Especially if you have links between certain types of data. Or when you have lots of different data types. INI files seem to be much easier now but just try to get a bit more experience with XML and you might one day even forget how much you prefer INI files. :-)
For a previous employer I did write my own TIniFile class (but can't share the code) which would also handle huge INI files. It was especially written for that purpose but even though it was quite fast, the INI file format just always turned out to be too limiting. My employer was considering to replace the INI file with an XML file instead but unfortunately that company went tits up before we had the chance to change it.
>I replaced the IniFiles.pas with IniFiles32.pas and it works fine. My greatis iniinspector works fine
>I find ini files much easier to use so no one was able to answer the question that I gave.

If you can replace TIniFile with TIniFile32, why was TMemIniFile a non-answer? Just wondering.

uses  {...} IniFiles;

procedure TForm1.Button1Click(Sender: TObject);
  with TMemIniFile.Create(fn) do begin
     for i:=0 to 100 do begin
        for j:=0 to 100 do
          WriteString('Section '+IntToStr(i), IntToStr(j), 'Some Value '+IntToStr(i)+'.'+IntToStr(j));
   ShowMessage('Ini File Size: '+IntToStr(ShowFSize(fn)));

function TForm1.ShowFSize(FName:String):Int64;
  SRec : TSearchRec;
  if FindFirst(FName, faAnyFile, SRec ) = 0 then
     Result:=Int64(SRec.FindData.nFileSizeHigh) shl Int64(32) + Int64(SRec.FindData.nFileSizeLow)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now