Solved

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
8
205 Views
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

Ben
0
Comment
Question by:Alpha_AI
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 28

Accepted Solution

by:
TName earned 40 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...
0
 
LVL 17

Assisted Solution

by:Wim ten Brink
Wim ten Brink earned 60 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.)
0
 
LVL 17

Expert Comment

by:TheRealLoki
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
Loki
0
 

Author Comment

by:Alpha_AI
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.

Ben
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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"?>
<Configuration>
  <Section name="Section1">
    <Key name="SomeKeyName1">SomeValue</Key>
    <Key name="SomeKeyName2">SomeValue</Key>
    <Key name="SomeKeyName3">SomeValue</Key>
    <Key name="SomeKeyName4">SomeValue</Key>
  </Section>
  <Section name="Section2">
    <Key name="SomeKeyName5">SomeValue</Key>
    <Key name="SomeKeyName6">SomeValue</Key>
  </Section>
</Configuration>

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:
C:\WINDOWS\system32\msxml.dll
C:\WINDOWS\system32\msxml2.dll

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.)
0
 

Author Comment

by:Alpha_AI
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
0
 
LVL 17

Assisted Solution

by:Wim ten Brink
Wim ten Brink earned 60 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.
0
 
LVL 28

Expert Comment

by:TName
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);
var
i,j:Integer;
fn:String;
begin
  fn:=ExtractFilePath(ParamStr(0))+'SizeTest.ini';
  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));
        Application.ProcessMessages;
     end;
     UpdateFile;
     Free;
  end;
   ShowMessage('Ini File Size: '+IntToStr(ShowFSize(fn)));
end;

function TForm1.ShowFSize(FName:String):Int64;
var
  SRec : TSearchRec;
begin
  if FindFirst(FName, faAnyFile, SRec ) = 0 then
     Result:=Int64(SRec.FindData.nFileSizeHigh) shl Int64(32) + Int64(SRec.FindData.nFileSizeLow)
  else
     Result:=0;
  FindClose(SRec);
end;
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now