Sign in to follow this  
Followers 0
Tlem

Strange behavior with IniReadSectionNames

7 posts in this topic

Hello everybody.

I have search on the forum and on the bug tracker, but I doesn't find any similar behavior.

I would like to expose a strange thing about the function IniReadSectionNames.

On some files, It seems that this function take sections name on other way that the file himself.

You can take a look by this demo code :

#include <Array.au3>
#include <String.au3>

; Only on this two files, the number of sections is different !!!
_IniView(@WindowsDir & "\win.ini")
_IniView(@WindowsDir & "\system.ini")

; And more strange, IniReadSectionNames can read file that doesn't exist !!!
FileMove(@WindowsDir & "\win.ini", @WindowsDir & "\winold.ini")
Local $aIniSections = IniReadSectionNames(@WindowsDir & "\win.ini")
FileMove(@WindowsDir & "\winold.ini", @WindowsDir & "\win.ini")
_ArrayDisplay($aIniSections, "did you have sections ?")

Func _IniView($Ini_File)
     ; Ini Section by FileRead
     $sIni = FileRead($Ini_File)
     Local $aIniSections1 = _StringBetween($sIni, "[", "]", 1)
     _ArrayInsert($aIniSections1, 0, UBound($aIniSections1))

     ; Ini Section by IniReadSectionNames
     Local $aIniSections2 = IniReadSectionNames($Ini_File)

_ArrayDisplay($aIniSections1, "Ini By FileRead")
_ArrayDisplay($aIniSections2, "Ini By IniReadSectionNames")
EndFunc ;==>_IniView

As you can see, it affects only system ini files (even if they are not present) ...

I doesn't know if it's a bug, but it is really strange.


Best Regards.Thierry

Share this post


Link to post
Share on other sites



Search for IniFileMapping

Share this post


Link to post
Share on other sites

Ini format is old, almost legacy thing for Windows systems. Many people don't know that these functions will read registry before ini files even if you specify file. This is the case here. Registry is read, not your file.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Are you sure the FileMove of the ini file was successfull? It's a system Ini file so I would expect an error to be returned by FileMove.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Well, It seems that my search was not rather precise. :x

But on this big forum, the subject was related only two time.

I understand now why this append, But isn't it sensible to add this information in the documentation?

@trancexx

Yes, Ini format is old, but it still used even in Windows 8. ;)


Best Regards.Thierry

Share this post


Link to post
Share on other sites

@trancexx

Yes, Ini format is old, but it still used even in Windows 8. ;)

Your point is what?

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Just a note in the documentation. :)

Edit : May be it's possible to add an option which would allow the reading/writing forced of the .ini file.

I have read this informations GetPrivateProfileString, WritePrivateProfileString, GetProfileString, WriteProfileString and it seems to be possible.

Yes it one is crowned modification for so little thing, but it is an idea as the other one...

Many people don't know that these functions will read registry before ini files even if you specify file.

May be can you take consideration of in 2009, what would set certainly less time than the modification of the functions, or the processing of ceaseless questions or bug repport. Edited by Tlem

Best Regards.Thierry

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0