Sign in to follow this  
Followers 0
Lapone

Help for .inf file

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I try to save a section from an .inf file like this:

[software.AddReg]

0x1,"Classes\CLSID\{05589FAF-C356-11CE-BF01-00AA0055595A}",,"Audio Renderer Property Page"

0x2,"Classes\CLSID\{05589FAF-C356-11CE-BF01-00AA0055595A}\InprocServer32",,"quartz.dll"

0x1,"Classes\CLSID\{05589FAF-C356-11CE-BF01-00AA0055595A}\InprocServer32","ThreadingModel","Both"

0x1,"Classes\CLSID\{060AF76C-68DD-11D0-8FC1-00C04FD9189D}",,"Seeking"

; RegServer wmpui.dll - - No output

0x2,"Classes\CLSID\{060AF76C-68DD-11D0-8FC1-00C04FD9189D}\InprocServer32",,"wmpui.dll"

0x1,"Classes\CLSID\{060AF76C-68DD-11D0-8FC1-00C04FD9189D}\InprocServer32","ThreadingModel","Both"

[setupReg.AddReg]

0x2,"ControlSet001\Services\EventLog\Application\WmdmPmSN","EventMessageFile","mspmsnsv.dll"

0x1,"ControlSet001\Services\WmdmPmSN","Description","Retrieves the serial number of any portable media player connected to this computer. If this service is stopped, protected content might not be down loaded to the device."

0x1,"ControlSet001\Services\WmdmPmSN","DisplayName","Portable Media Serial Number Service"

0x4,"ControlSet001\Services\WmdmPmSN","ErrorControl",0x1

0x2,"ControlSet001\Services\WmdmPmSN","ImagePath","System32\svchost.exe -k netsvcs"

[software.AddReg]

0x1,"Classes\Interface\{20D4F5E0-5475-11D2-9774-0000F80855E6}",,"IMediaPlayer2"

0x1,"Classes\Interface\{20D4F5E0-5475-11D2-9774-0000F80855E6}\ProxyStubClsid",,"{00020424-0000-0000-C000-000000000046}"

0x1,"Classes\Interface\{20D4F5E0-5475-11D2-9774-0000F80855E6}\ProxyStubClsid32",,"{00020424-0000-0000-C000-000000000046}"

0x1,"Classes\Interface\{20D4F5E0-5475-11D2-9774-0000F80855E6}\TypeLib",,"{22D6F304-B0F6-11D0-94AB-0080C74C7E95}"

0x1,"Classes\Interface\{20D4F5E0-5475-11D2-9774-0000F80855E6}\TypeLib","Version","1.0"

with this code:

$Section = "Software.AddReg"
$INIContents = FileRead("Some.inf")


$Position = StringInStr($INIContents, "[" & $Section & "]")
    If $Position > 0 Then
        $PosEndSection = StringInStr(StringMid($INIContents, $Position + 1), "[") + ($Position - 2)
        If $PosEndSection = 0 Then $PosEndSection = StringLen($INIContents) + 1
        $sContents = StringMid($INIContents, $Position, $PosEndSection - $Position)
MsgBox(4096, "", $sContents)
EndIf

but the commented line that contains result the end section.

I need to change the "[" in the $PosEndSection line, but I still have not figured out so if someone has some hints......... :"> also on merging duplicate sections.

Any Help is really appreciated!

Edited by Lapone

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This might not be the simplest way but using some Array.au3 UDF's the line's can be removed without much trouble

Try adding this line after your file read:

$INIContents = Remove_Comments($ThisInf)oÝ÷ Ø    ݶ¬éܶ*'jëh×6Func Remove_Comments($File) ;Removes lines beginning in ";"
    Local $SplitBefore, $SplitAfter, $RemovedItems, $Line
    $SplitBefore = StringSplit($File, @CRLF, 1 )
    $SplitAfter = $SplitBefore
    $RemovedItems = 0
    For $Line = 1 To $SplitBefore[0]
        If StringLeft($SplitBefore[$Line], 1) = ";" Then ;to remove blank lines add 'Or $SplitBefore[$Line] = ""' here
            _ArrayDelete($SplitAfter, $Line-$RemovedItems )
            $RemovedItems += 1
        EndIf
    Next
    Return _ArrayToString( $SplitAfter, @CRLF, 1 )
EndFunc

Also remember to add:

#include <array.au3>

Edited by Gabburd

Share this post


Link to post
Share on other sites

This might not be the simplest way but using some Array.au3 UDF's the line's can be removed without much trouble

Try adding this line after your file read:

$INIContents = Remove_Comments($ThisInf)
Gabburd, Thanks a lot.. :shocked:

Any advice how to merge the 2 [software.AddReg] sections?

Please

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