Jump to content

Request UDF for INF File Processing Functions


DXRW4E
 Share

Recommended Posts

I think you dont understand the nature of this forum.

Here you give your example scripts for other people to use.

If you are trying to make your own, you can get help with it in the Help forum.

If you want someone to code it for you, you can go to a site like rentacoder and pay someone.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I apologize if wrong section

No, or no intention to pay anyone

However, those functions and idea of ​​being helpful to everyone, not just me, basic idea and be able to read quickly and without limits an ini or inf file section, as is known in autoit IniRead to limitations

with StringRegExp or fate funtion to read the inf (Windows INF file format) section, and they work very well, but unfortunately also StringRegExp to the limits, I do not read larger sections of 8 mb ect ect, just thought that maybe a UDF inf would be very helpful to everyone,

more inf and ini normal, is not the same as the Windows INF file format, this is very important (also here with me StringRegExp from me I could get everything I want, but it would be faster and from setupapi.dll best)

Anyway thanks for your answer

Sorry again for my English, Ciao.

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

Try this UDF example

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

based on the work of SmOke_N, 1 year ago or (modified, updated, created) function that are OK, because the function of the Ini+Ex, have to read normal INI/INF, not Windows INF file format, example

[sectionname]

Co\

mp\;;; comment Ect ect ect

onent_Nam\

e\

=\

\;;; comment Ect ect ect

advpack.dll,LaunchINFSection,\

\;;; commento Ect ect ect

INF_FileName,SectionName

and equal = Component_Name=advpack.dll,LaunchINFSection,INF_FileName,SectionName

Or

[sectionname]

Co\

mp"\"\;;; comment Ect ect ect

onent_Nam"="\

e\

=\

\;;; comment Ect ect ect

advpack.dll,LaunchI";"NFSection,\

\;;; commento Ect ect ect

INF_FileName,SectionName

and equal = Comp\onent_Nam=e = advpack.dll,LaunchI;NFSection,INF_FileName,SectionName

and everything is OK, I can do the StringRegExp, almost 99% of what he does setupapi, but I can not read sections, longer than 4-5-6-7 MB, in this case use the stringsplit, and everything is OK after, what I meant, and that StringRegExp to its limits, is still not enough, instead of doing everything from setupapi To be an all will have faster and more secure

Thanks again for the answer, Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

That's not a standard Windows INF file format, I'm not sure where that file is from, but a valid INF file is setup exactly like an INI file. At least every one that I've ever looked at.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

and the windows setup inf mod, from advpack.dll,LaunchINFSection or setupapi.dll,InstallHinfSection

look here for more http://msdn.microsoft.com/en-us/library/aa377388%28v=VS.85%29.aspx

Ciao.

I went to that link, there's nothing there that tells me that the INF file format you posted is valid for any Windows INF file.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I went to that link, there's nothing there that tells me that the INF file format you posted is valid for any Windows INF file.

look here http://msdn.microsoft.com/en-us/library/ff544990%28v=vs.85%29.aspx

I can not say I'm a professional about it but I'm almost 8 years I write some inf, I can say or a bit of experience

Open notepad, copy this line, save it as test.inf, click on the file inf install, and you'll see that inf and operated fully

[Version]

Signature="$Windows NT$"

[DefaultInstall]

Add\

Reg =he\

llo.A\

ddReg, hi.\

AddReg

Addreg = bye-bye.AddReg, "bye,bye,AddReg"

[hello.AddReg]

HKCR,"..hello","hello",,"hello"

[hi.AddReg]

HKCR,"..hi","hi",,"hi"

[bye-bye.AddReg]

HKCR,"..bye-bye","bye-bye",,"bye-bye"

[bye,bye,AddReg]

HKCR,"..bye,bye","bye,bye",,"bye,bye"

the inf that Microsoft uses in its setup, such as Windows 2000/XP/2003 ect ect ec

Sorry again for my English

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

I see what you're talking about now, the backslash is a line continuation character in the ini/inf format. IniRead doesn't recognize that the next line is a continuation of the previous line. So you'll either have to reformat those INF files to be readable by iniread, or you'll have to come up with a way of reading the file with some form of FileReadxxx and create your own file parser.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

them and all ok, I can do everything almost perfectly, by function created in autoit, what is lacking and read an entire section of the inf section that will be able To be an even 1000000 line, and this is done or just using stringsplit, or using the setupapi.dll

example

inf file = @DesktopDir & "\2.inf"

[Version]

signature="$Windows NT$"

Addreg = 1.addreg, 2.addreg

ClassGUID=%ClassGUID%

Layo\\\\\\\\\\\\\\\ ;ffffffffff

utF\

ile\

=\

la\;ffffffff

yo\

u\;jjjjjjjjjjjjjj

t.inf

%DRVV%=07/01/2001,5.1.2600.5512

Addreg = 3.addreg, 4.addreg

;string, will be able To be an even local, such as ENU = [strings.0409]

[strings]

ClassGUID = {00000000-0000-0000-0000-000000000000}

DRVV = DriverVer

in inf file about 30 mb, _DXF_GetPrivateProfileSection and almost 80% faster of _IniReadSectionEx, because they use the StringSplit, Instead in the inf file smaller than 5 mb, when using the stringregexp and almost 120% faster

Local  $sss, $begin, $dif
$begin = TimerInit()
$sss = _DXF_GetPrivateProfileSection(@DesktopDir & "\2.inf", "Version", 0, "")
$dif = TimerDiff($begin)
MsgBox(0, $dif, $sss)
MsgBox(0, "LayoutFile", _DXF_GetPrivateProfileString(@DesktopDir & "\2.inf", "Version", "LayoutFile", 0, 0, 0, "0409"))
MsgBox(0, "ClassGUID", _DXF_GetPrivateProfileString(@DesktopDir & "\2.inf", "Version", "ClassGUID", 0, 0, 0, "0409"))
MsgBox(0, "DriverVer", _DXF_GetPrivateProfileString(@DesktopDir & "\2.inf", "Version", "DriverVer", 0, 0, 0, "0409"))
MsgBox(0, "Addreg", _DXF_GetPrivateProfileString(@DesktopDir & "\2.inf", "Version", "Addreg"))
MsgBox(0, "Addreg2", _DXF_GetPrivateProfileString(@DesktopDir & "\2.inf", "Version", "Addreg", 0, 1))
Exit
 
Func _DXF_GetPrivateProfileSection($DXF_GPPSPFile, $DXF_GPPSName, $DXF_GPPSRSS = 0, $DXF_GPPSVR = "")
    $DXF_GPPSPFile = FileRead($DXF_GPPSPFile)
    If @Error Then Return SetError(1, 0, "")
    $DXF_GPPSPFile = StringRegExpReplace($DXF_GPPSPFile, '\r(?!\n)', @CRLF)   ;StringRegExpReplace(, '(?<!\r)\n', @CRLF)
    Local $DXF_GPPSRDSF, $DXF_GPPSTMP, $DXF_GPPSCSS, $DXF_GPPSLVSR, $DXF_GPPSPFGS = 1, $DXF_GPSOPTS = 0
    If Stringlen($DXF_GPPSPFile) < 4996000 Then $DXF_GPPSPFGS = 0
 
    If Not $DXF_GPPSPFGS Then
        $DXF_GPPSName = StringSplit(@LF & StringReplace($DXF_GPPSName, "\E", "\e"), @LF) ;StringRegExpReplace($DXF_GPPSName, '[\^\$\\\/\(\)\|\?\+\*\[\]\{\}\,\.\:\<\>\=]', "\\$0"), @LF)
        For $n = 2 To $DXF_GPPSName[0]
            If $DXF_GPPSName[$n] = "" Then ContinueLoop
            $DXF_GPPSTMP = StringRegExp(@LF & $DXF_GPPSPFile & @CRLF & "[", '(?s)(?i)\n\h*\[\Q' & $DXF_GPPSName[$n] & '\E\][^\r\n]*\s*(?(?=\n\h*\[)\h*|\n)(.*?)(?=[\r\n]\s*\[)', 3)
            If @Error Then ContinueLoop
            $DXF_GPPSCSS = 1
            If $DXF_GPPSRSS Then ;return only the first section found
                If $DXF_GPPSTMP[0] <> "" Then $DXF_GPPSRDSF &= $DXF_GPPSTMP[0] & @CRLF
                ExitLoop
            ElseIf UBound($DXF_GPPSTMP) > 1 Then
                For $a = 0 To UBound($DXF_GPPSTMP) - 1
                    If $DXF_GPPSTMP[$a] <> "" Then $DXF_GPPSName[1] &= $DXF_GPPSTMP[$a] & @CRLF
                Next
                $DXF_GPPSRDSF &= $DXF_GPPSName[1]
            Else
                If $DXF_GPPSTMP[0] <> "" Then $DXF_GPPSRDSF &= $DXF_GPPSTMP[0] & @CRLF
            EndIf
        Next
    Else
        If $DXF_GPPSRSS Then $DXF_GPSOPTS = 2
        $DXF_GPPSPFile = _DXF_GetProfileSection($DXF_GPPSPFile, 0, $DXF_GPPSName, $DXF_GPSOPTS)
        $DXF_GPPSCSS = @Extended
        $DXF_GPPSRDSF = $DXF_GPPSPFile[3]
        If $DXF_GPPSCSS Then
            $DXF_GPPSPFile = $DXF_GPPSPFile[1] & $DXF_GPPSPFile[2] & $DXF_GPPSPFile[3] & @CRLF & @CRLF & $DXF_GPPSPFile[4]
        Else
            $DXF_GPPSPFile = $DXF_GPPSPFile[1]
        EndIf
    EndIf
    If $DXF_GPPSRDSF = "" Then Return SetError(3, $DXF_GPPSCSS, "")
    If $DXF_GPPSVR And StringRegExp($DXF_GPPSRDSF, '%.*?%') Then
        If Not StringInStr($DXF_GPPSVR, @LF) Then   ;;; $DXF_GPPSVR = 0409 or string section read - aaa=bbb & @CRLF & ccc=dddd & @CRLF & eee=fff  ect ect
            $DXF_GPPSVR = StringRegExp(@LF & $DXF_GPPSPFile & @CRLF & "[", '(?s)(?i)\n\h*\[\Q' & "Strings." & $DXF_GPPSVR & '\E\][^\r\n]*\s*(?(?=\n\h*\[)\h*|\n)(.*?)(?=[\r\n]\s*\[)', 3)
            If @Error Then $DXF_GPPSVR = StringRegExp(@LF & $DXF_GPPSPFile & @CRLF & "[", '(?s)(?i)\n\h*\[Strings\][^\r\n]*\s*(?(?=\n\h*\[)\h*|\n)(.*?)(?=[\r\n]\s*\[)', 3)
            If IsArray($DXF_GPPSVR) Then
                $DXF_GPPSVR = $DXF_GPPSVR[0]
            Else
                $DXF_GPPSVR = 0
            EndIf
        EndIf
        If $DXF_GPPSVR Then
            $DXF_GPPSVR = @CRLF & $DXF_GPPSVR & @CRLF
            Local $DXF_GPPASTMP, $DXF_GPPSVARC  ;;;;, $DXF_GPPSSKVS = StringRight($DXF_GPPSVR, 1)
            $DXF_GPPSVARC = StringRegExp($DXF_GPPSRDSF, '(%.*?%)', 3)
            If Not @error Then
                For $i = 1 To UBound($DXF_GPPSVARC) - 1
                    If Not StringRegExp($DXF_GPPSVARC[0], "\Q" & $DXF_GPPSVARC[$i] & "\E") Then $DXF_GPPSVARC[0] &= $DXF_GPPSVARC[$i]
                Next
                $DXF_GPPSVARC = StringSplit(StringTrimLeft(StringTrimRight($DXF_GPPSVARC[0], 1), 1), "%%", 1)
                For $i = 1 To $DXF_GPPSVARC[0]
                    If StringStripWS($DXF_GPPSVARC[$i], 1) = "" Then ContinueLoop
                    $DXF_GPPASTMP = StringRegExp($DXF_GPPSVR, '(?i)\n\h*(' & StringRegExpReplace('"*' & StringRegExpReplace(StringRegExpReplace($DXF_GPPSVARC[$i], '(.)', "$1" & @LF), '[\^\$\\\/\(\)\|\?\*\+\[\]\{\}\,\.\:\<\>\=]', "\\$0"), @LF, '(?:"*\\h*\\\\[\\h\\\\]*(?:\\r?\\n|;.*\\n)\\h*)*"*') & ')[\h*\\]*=\h*((?:[^"\\;\n]|"[^"\n]*"|\\[\h\\]*(?:\r?\n|;.*\n)|\\|"[^\n]*|;[^\n]*)*?)\h*(?=\n)', 3)  ;;; '\h*((?(?=(?:(?:[^";\n]|"[^"\n]*")*?)\\\h*(\r?\n|;.*\n)).*?\n|(?:(?(?=\h*;.*\n).*?\n|[^\n]*)*?))*?)\h*(?=\n)'
                    If Not @Error And StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($DXF_GPPASTMP[0], '((?:[^";\r\n]|"[^"\r\n]*")*?);[^\n]*', "$1"), '"(.*?)"', "$1") & @LF, '[\h\\]*\r?\n\h*', "") = $DXF_GPPSVARC[$i] Then
                        $DXF_GPPASTMP[1] = StringReplace(StringRegExpReplace($DXF_GPPASTMP[1] & @LF, '\h*((?:[^";\r\n]|"[^"\r\n]*"|"[^\r\n]*)*?)[\h\\]*(?:;[^\n]*)?\r?\n\h*', "$1"), '"', "")
                        $DXF_GPPSRDSF = StringRegExpReplace($DXF_GPPSRDSF, "(?i)\Q%" & $DXF_GPPSVARC[$i] & "%\E", StringRegExpReplace(StringRegExpReplace($DXF_GPPASTMP[1], '\\', "\\\\"), '\$', "\\$"))
                        ;If @Extended Then $DXF_GPPSLVSR &= @LF & $DXF_GPPSVARC[$i] & @CR & $DXF_GPPASTMP[1]  ;;;personal use, save, to restore them after modification of the section
                    EndIf
                Next
            EndIf
        EndIf
    EndIf
    Return SetError(0, $DXF_GPPSCSS, $DXF_GPPSRDSF)
EndFunc
 
Func _DXF_GetPrivateProfileString($DXF_GPPSSSC, $DXF_GPPSSSN, $DXF_GPPSSKN, $DXF_GPPSSSCWS = 0, $DXF_GPPSSGAV = 0, $DXF_GPPSSWM = 0, $DXF_GPPSSLL = 0, $DXF_GPPSSOPT = "")
    If StringStripWS($DXF_GPPSSKN, 3) = "" Then SetError(1, 0, $DXF_GPPSSOPT)
    If $DXF_GPPSSSN Then $DXF_GPPSSSC = _DXF_GetPrivateProfileSection($DXF_GPPSSSC, $DXF_GPPSSSN, 0, $DXF_GPPSSLL)
    If @Error Then SetError(2, 0, $DXF_GPPSSOPT)
    If Not $DXF_GPPSSSCWS Then $DXF_GPPSSSCWS = "="
    Local $DXF_GPPSSGAVTMP, $DXF_GPPSCED, $DXF_GPPSSWP = ')\h*' & $DXF_GPPSSSCWS & '(.*?)(?=[\r\n])', $DXF_GPPSSKNPM = StringRegExpReplace('"*' & StringRegExpReplace(StringRegExpReplace($DXF_GPPSSKN, '(.)', "$1" & @LF), '[\^\$\\\/\(\)\|\?\*\+\[\]\{\}\,\.\:\<\>\=]', "\\$0"), @LF, '(?:"*\\h*\\\\[\\h\\\\]*(?:\\r?\\n|;.*\\n)\\h*)*"*')
    If Not $DXF_GPPSSWM Then $DXF_GPPSSWP = ')[\h*\\]*' & $DXF_GPPSSSCWS & '\h*((?:[^"\\;\n]|"[^"\n]*"|\\[\h\\]*(?:\r?\n|;.*\n)|\\|"[^\n]*|;[^\n]*)*?)\h*(?=\n)'  ;;; '\h*((?(?=(?:(?:[^";\n]|"[^"\n]*")*?)\\\h*(\r?\n|;.*\n)).*?\n|(?:(?(?=\h*;.*\n).*?\n|[^\n]*)*?))*?)\h*(?=\n)'
    $DXF_GPPSSSC = StringRegExp(@LF & $DXF_GPPSSSC & @LF, '(?i)\n\h*(' & $DXF_GPPSSKNPM & $DXF_GPPSSWP, 3)
    If @Error Then Return SetError(3, 0, $DXF_GPPSSOPT)
    For $i = 1 To UBound($DXF_GPPSSSC) - 1 Step 2
        If StringCompare(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($DXF_GPPSSSC[$i - 1], '((?:[^";\r\n]|"[^"\r\n]*")*?);[^\n]*', "$1"), '"(.*?)"', "$1") & @LF, '[\h\\]*\r?\n\h*', ""), $DXF_GPPSSKN) Then ContinueLoop
        If Not $DXF_GPPSSGAV Then
            If $DXF_GPPSSWM Then Return $DXF_GPPSSSC[$i]
            Return StringReplace(StringRegExpReplace($DXF_GPPSSSC[$i] & @LF, '\h*((?:[^";\r\n]|"[^"\r\n]*"|"[^\r\n]*)*?)[\h\\]*(?:;[^\n]*)?\r?\n\h*', "$1"), '"', "")
        EndIf
        $DXF_GPPSCED = StringRegExp("," & $DXF_GPPSSSC[$i], ',((?:(?:[^",;\r\n]|"[^"\r\n]*")*?)"[^"\r\n]*)\r?\n?$', 3)
        If Not @Error Then $DXF_GPPSSSC[$i] = StringReplace($DXF_GPPSSSC[$i], $DXF_GPPSCED[0], '"' & StringReplace($DXF_GPPSCED[0], '"', "") & '"', -1)
        $DXF_GPPSSGAVTMP &= "," & $DXF_GPPSSSC[$i] & @LF
    Next
    If Not $DXF_GPPSSGAVTMP Then Return SetError(3, 0, $DXF_GPPSSOPT)
    $DXF_GPPSSGAVTMP = StringRegExpReplace(StringTrimLeft($DXF_GPPSSGAVTMP, 1) & @LF, '((?:[^";\r\n]|"[^"\r\n]*"|"[^\r\n]*)*?)[\h\\]*(?:;[^\n]*)?\r?\n\h*', "$1")   ;;;;;;;;;;; & @LF, '([\h\\]+(?:;[^\n]*)*|\n\h*;.*?)(?=\n)', ""), '[\h\\]*\r?\n\h*', "")
    If $DXF_GPPSSGAV < 2 Then $DXF_GPPSSGAVTMP = StringRegExpReplace($DXF_GPPSSGAVTMP, '"', "")
    Return $DXF_GPPSSGAVTMP
EndFunc
 
Func _DXF_GetProfileSection($DXF_GPSPFile, $DXF_GPSCFS, $DXF_GPSName, $DXF_GPSOPT = 0)
    ;If $DXF_GPSCFS > 1 Then $DXF_GPSPFile = FileRead($DXF_GPSPFile)
    ;If @Error Then Return SetError(1, 0, "")
    ;If $DXF_GPSCFS Then $DXF_GPSPFile = StringRegExpReplace($DXF_GPSPFile, '\r(?!\n)', @CRLF)   ;StringRegExpReplace(, '(?<!\r)\n', @CRLF)
    Local $DXF_GPSFOFS, $DXF_GPSPFileTMP, $NEWDXFGPSPFile[8] = ["", $DXF_GPSPFile, "[" & $DXF_GPSName & "]" & @CRLF], $DXF_GPSCSS
    If StringRight($DXF_GPSName, 1) = @LF Then $DXF_GPSFOFS = 1
 
    $DXF_GPSName = StringSplit(StringReplace($DXF_GPSName, "\E", "\e"), @LF)
    For $i = 1 To $DXF_GPSName[0]
        If $DXF_GPSName[$i] = "" Then ContinueLoop
        $DXF_GPSPFile = StringSplit(StringRegExpReplace(@LF & $DXF_GPSPFile & @LF, '(?s)(?i)(\n\h*\[\Q' & $DXF_GPSName[$i] & '\E\][^\r\n]*\h*\r)(?=[\n])', @LF & "[" & StringRegExpReplace(StringRegExpReplace($DXF_GPSName[$i], "\\", "\\\\"), '\$', "\\$") & "]"), @LF & "[" & $DXF_GPSName[$i] & "]" & @LF, 1)
        If @Error Then
            $DXF_GPSPFile = StringTrimLeft(StringTrimRight($DXF_GPSPFile[1], 2), 1)
            ContinueLoop
        EndIf
        $DXF_GPSCSS = 1
        If $DXF_GPSOPT <> 2 Then
            Local $NEWDXFGPSPFile[8] = ["", StringTrimLeft($DXF_GPSPFile[1], 1) & @LF, "[" & $DXF_GPSName[$i] & "]" & @CRLF]
            For $n = 2 To $DXF_GPSPFile[0]
                $DXF_GPSPFileTMP = StringRegExp($DXF_GPSPFile[$n] & @LF & "[", '(\n\h*\[)', 3)
                $DXF_GPSPFileTMP = StringInStr($DXF_GPSPFile[$n] & @LF & "[", $DXF_GPSPFileTMP[0])
                $NEWDXFGPSPFile[3] &= StringStripWS(StringLeft($DXF_GPSPFile[$n], $DXF_GPSPFileTMP), 2) & @CRLF
                $NEWDXFGPSPFile[4] &= StringTrimLeft($DXF_GPSPFile[$n], $DXF_GPSPFileTMP) & @LF
            Next
            If $DXF_GPSFOFS Then ExitLoop
            $NEWDXFGPSPFile[4] = StringTrimRight($NEWDXFGPSPFile[4], 1)
            $DXF_GPSPFile = $NEWDXFGPSPFile[1] & $NEWDXFGPSPFile[2] & $NEWDXFGPSPFile[3] & @CRLF & @CRLF & $NEWDXFGPSPFile[4]
        Else
            $DXF_GPSPFileTMP = StringRegExp($DXF_GPSPFile[2] & @LF & "[", '(\n\h*\[)', 3)
            Return SetError(0, $DXF_GPSCSS, StringStripWS(StringLeft($DXF_GPSPFile[2], StringInStr($DXF_GPSPFile[2] & @LF & "[", $DXF_GPSPFileTMP[0])), 2) & @CRLF)
        EndIf
    Next
    If $DXF_GPSOPT = 1 Then SetError(0, $DXF_GPSCSS, $NEWDXFGPSPFile[3])
    $NEWDXFGPSPFile[4] = StringTrimRight($NEWDXFGPSPFile[4], 1)
    If $DXF_GPSCSS Then SetError(0, $DXF_GPSCSS, $NEWDXFGPSPFile)
    Return SetError(1, $DXF_GPSCSS, $NEWDXFGPSPFile)
EndFunc

now or since, In + Ex Functions have been updated, however still have a problem, _IniReadSectionEx not read correctly empty sections, example

[sectionname1]

[sectionname2]

aaa = bbb

ccc = ddd

_IniReadSectionEx($v_file, "sectionname1") also return "sectionname2", necesito use "(?(?=\n\h*\[)\h*|\n)"

using setupapi.dll it would be really nice, although as you can see, even with using function in stringregexp, and everything ok, but using setupapi.dll, things should be faster and more secure

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

  • 2 years later...

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
 Share

  • Recently Browsing   0 members

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