Inf-Datei auslesen

  • Hilft dir folgendes weiter?:

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    $hFFFF = FileFindFirstFile("Inf-Dateien\*.inf")

    [/autoit] [autoit][/autoit] [autoit]

    If $hFFFF <> -1 Then
    Do
    $sfile = FileFindNextFile($hFFFF)
    If @error Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    $sText = FileRead("Inf-Dateien\" & $sfile)
    $aStringSection = IniReadSection("Inf-Dateien\" & $sfile, "Strings")
    If Not @error Then
    For $i = 1 To $aStringSection[0][0]
    $sText = StringReplace($sText, "%" & $aStringSection[$i][0] & "%", StringTrimLeft(StringTrimRight($aStringSection[$i][1], 1), 1))
    Next
    EndIf
    $hInfFile = FileOpen(@TempDir & '\Temp.inf', 2)
    FileWrite($hInfFile, $sText)
    FileClose($hInfFile)

    [/autoit] [autoit][/autoit] [autoit]

    $Modell = GetModell(@TempDir & '\Temp.inf')
    If Not @error THen
    If StringLeft($Modell, 1) = '"' Then $Modell = StringTrimLeft($Modell, 1)
    If StringRight($Modell, 1) = '"' Then $Modell = StringTrimRight($Modell, 1)
    ConsoleWrite($Modell & @CRLF)
    EndIf
    Until 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    FileDelete(@TempDir & '\Temp.inf')

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func GetModell($sfile)
    Local $sModell
    Local $aManufactor = IniReadSection($sfile, "Manufacturer")

    [/autoit] [autoit][/autoit] [autoit]

    If Not @error Then
    $aModel = IniReadSection($sfile, StringReplace($aManufactor[1][1], ',', '.'))
    If Not @error Then
    Return $aModel[1][0]
    Else
    $aModel = IniReadSection($sfile, $aManufactor[1][0])
    If Not @error Then
    Return $aModel[1][0]
    Else
    $aStrSpl = StringSplit($aManufactor[1][1], ',')
    If Not @error Then
    $aModel = IniReadSection($sfile, $aStrSpl[1])
    If Not @error Then Return $aModel[1][0]
    EndIf
    EndIf
    EndIf
    Else
    $sRegexp = StringRegExp(FileRead($sfile), "\[Manufacturer\]\r\n(.+)\r", 3)
    If Not @error Then
    If StringLeft($sRegexp[0], 1) = '"' Then $sRegexp[0] = StringTrimLeft($sRegexp[0], 1)
    If StringRight($sRegexp[0], 1) = '"' Then $sRegexp[0] = StringTrimRight($sRegexp[0], 1)
    $aModel = IniReadSection($sfile, $sRegexp[0])
    If Not @error Then Return $aModel[1][0]
    EndIf
    EndIf
    Return SetError(1,0,"")
    EndFunc ;==>GetModell

    [/autoit] [autoit][/autoit] [autoit][/autoit]