Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2006-11-08
Medium Priority
Last Modified: 2010-04-05
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

Question by:Alpha_AI
  • 3
  • 2
  • 2
  • +1
LVL 28

Accepted Solution

TName earned 160 total points
ID: 17898276
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...
LVL 17

Assisted Solution

by:Wim ten Brink
Wim ten Brink earned 240 total points
ID: 17901020
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.)
LVL 17

Expert Comment

ID: 17902803
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

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 17903603
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.

LVL 17

Expert Comment

by:Wim ten Brink
ID: 17904787
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.)

Author Comment

ID: 17905831
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
LVL 17

Assisted Solution

by:Wim ten Brink
Wim ten Brink earned 240 total points
ID: 17906042
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.
LVL 28

Expert Comment

ID: 17907292
>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)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question