#141155 - 2005-06-07 06:33 PM
Re: ReadProfileString limitations?
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Richard,
You are correct. When Windows 95 was introduced, Microsoft had the limitation of 64kb for INI files. That is why the Registry is so heavily utilized for the OS.
Kent
|
|
Top
|
|
|
|
#141162 - 2005-06-08 03:02 AM
Re: ReadProfileString limitations?
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Well, so far I've not been able to find any Microsoft whitepaper saying if there is still a 64KB limit on the .INI file or not. I know that in the past this limit did exist, but perhaps not since the dawn of NT.
If that limit exists then yeah there is a problem with that STARTUP list.
2.7MB file size. - 2,720,590 StartupList.ini
|
|
Top
|
|
|
|
#141167 - 2005-06-08 10:39 AM
Re: ReadProfileString limitations?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
UDF to enumerate huge ini files.
Note, your will want to use native ReadProfileString() to read the entries in individual sections (unless they are also huge) as the process gets slower towards the end of the file.
Code:
Break ON $=SetOption("Explicit","ON") Dim $sIni,$sSections,$sEntries,$sSection,$sEntry $sIni=".\hugeini.ini" $sSections=udfEnumHugeIni($sIni) If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf For Each $sSection In Split($sSections,Chr(10)) "SECTION: "+$sSection+@CRLF $sEntries=udfEnumHugeIni($sINI,$sSection) If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf For Each $sEntry in Split($sEntries,Chr(10)) " ENTRY: "+$sEntry+@CRLF Next Next Exit 0 Function udfEnumHugeIni($sPath,Optional $sSection) Dim $fhIni,$sLine,$iSectionFlag,$sKey,$iExitFlag $udfEnumHugeIni="" $iExitFlag=0 $fhIni=FreeFileHandle() If @ERROR Exit @ERROR EndIF If Open($fhIni,$sPath) Exit @ERROR EndIf $sLine=ReadLine($fhIni) While Not @ERROR AND $iExitFlag=0 $sLine=Trim($sLine) $sKey="" If $sLine<>"" If Left($sLine,1)="[" If $iSectionFlag $iExitFlag=1 Else $iSectionFlag=0 If $sSection="" $sKey=SubStr($sLine,2,InStr($sline+"]","]")-2) EndIf If $sLine="["+$sSection+"]" $iSectionFlag=1 $sSection=" " EndIf EndIf Else If $iSectionFlag AND Left($sLine,1)<>";" $sKey=Left($sLine,InStr($sLine+"=","=")-1) EndIf EndIf EndIf If $sKey<>"" $udfEnumHugeIni=$udfEnumHugeIni+$sKey+Chr(10) EndIf $sLine=ReadLine($fhIni) Loop $iExitFlag=Close($fhINI) Exit 0 EndFunction
|
|
Top
|
|
|
|
#141168 - 2005-06-08 10:47 AM
Re: ReadProfileString limitations?
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Thanks Richard for the code... but onl reads sections
How would one use this to read both SECTIONS and real KEY data?
Sorry, maybe it already does and it's just too late and I'm too tired to see it.
Sample output was: Quote:
SECTION: BitDefender Scan Server ENTRY: Confirmed ENTRY: Filename ENTRY: Description ENTRY: Source ENTRY: SECTION: BitDefender Virus Shield ENTRY: Confirmed ENTRY: Filename ENTRY: Description ENTRY: Source ENTRY: SECTION: bitdefenderlive ENTRY: Confirmed ENTRY: Filename ENTRY: Description ENTRY: Source ENTRY: SECTION: BitDefender_P2P_Startup ENTRY: Confirmed ENTRY: Filename ENTRY: Description ENTRY: Source ENTRY:
|
|
Top
|
|
|
|
#141169 - 2005-06-08 01:23 PM
Re: ReadProfileString limitations?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Thanks Richard for the code... but onl reads sections
How would one use this to read both SECTIONS and real KEY data
Well this is just for enumerating the sections (and entry keys) where they might exceed the 32KB limit.
Once you have the section and/or key you would use the stock ReadProfileString() to read it.
To re-iterate my comments in the last post, unless your section is likely to contain more than 32KB of entry names, it is better to use ReadProfileString() to enumerate the entries once you've used udfEnumHugeIni() to get the section names.
For example: Code:
Break ON $=SetOption("Explicit","ON") Dim $sIni,$sSections,$sEntries,$sSection,$sEntry $sIni=".\hugeini.ini" $sSections=udfEnumHugeIni($sIni) If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf For Each $sSection In Split($sSections,Chr(10)) "SECTION: "+$sSection+@CRLF $sEntries=udfEnumHugeIni($sINI,$sSection) If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf For Each $sEntry in Split($sEntries,Chr(10)) " ENTRY: "+$sEntry+@CRLF " Data: "+ReadProfileString($sINI,$sSection,$sEntry)+@CRLF Next Next Exit 0
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 657 anonymous users online.
|
|
|