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
212 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 

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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 119
FMX StringGrid1->Canvas->FillRect Problem 3 176
Magic Software info 18 139
Delphi: barcode reading on android platform 1 52
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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