Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...