Sign in to follow this  
Followers 0
penggilas2

How To Search IniReadSectionNames

2 posts in this topic

#1 ·  Posted (edited)

Read ini File. : drive.ini

[partition1]

Driveletter=C:

Label=Windows Xp

[partition2]

Driveletter=D:

Label=Windows 7

[partition3]

Driveletter=E:

Label=Dokument

[partition4]

Driveletter=F:

Label=Recovery

Local $var = IniReadSectionNames("drive.ini")
If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $var[0]
   $MSG = IniRead("drive.ini", $var[$i], "LABEL", "NotFound")
   MsgBox(4096, "", $MSG)
    Next
EndIf

I want searcrh What is the section name of Windows Xp, Windows 7, Dokument,.. Thank's for All.. ;)

What is the script If i type windows xp .... will show partition1

Edited by penggilas2

Share this post


Link to post
Share on other sites



Try these methods.

Local $sTypedInLabel = "windows xp"
Local $sSectName
Local $var = IniReadSectionNames("drive.ini")
If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $var[0]
        If IniRead("drive.ini", $var[$i], "LABEL", "NotFound") = $sTypedInLabel Then
            $sSectName = $var[$i]
            ExitLoop
        EndIf
    Next
    MsgBox(0, "Find Section Name", $sTypedInLabel & ' from section name "' & $sSectName & '"')
EndIf

;Or

Local $sFile = FileRead("drive.ini")
If StringInStr($sFile, "Label=" & $sTypedInLabel) <> 0 Then _
        ConsoleWrite(StringRegExpReplace($sFile, "(?is).*\[(.*?)\].*?Label=" & $sTypedInLabel & ".*", "$1") & @LF)

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