Standard-Browser - UDF & _GetRegSubKeys

  • Hallo,

    Die Idee für diese UDF fiel mir vor ein paar Tagen spontan ein.
    Es kann schon sein das es so eine ähnliche UDF schon gibt, habe Google nicht gequält :D

    DefaultBrowser.au3
    [autoit]

    #include-once
    #include <Array.au3>

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

    Global Const $REG_X86_HKCU_DB = "HKCU\Software\Clients\StartMenuInternet"
    Global Const $REG_X86_HKLM_IB = "HKLM\Software\Clients\StartMenuInternet"

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

    Global Const $REG_X64_HKCU_DB = "HKCU64\Software\Clients\StartMenuInternet"
    Global Const $REG_X64_HKLM_IB = "HKLM64\Software\Clients\StartMenuInternet"

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

    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetDefaultBrowser
    ; Description ...: Returns the name of the default browser.
    ; Syntax ........: _GetDefaultBrowser()
    ; Parameters ....:
    ; Return values .: Success: Returns the name of the default browser.
    ; Failure: Returns 0
    ; Author ........: PainTain @ Autoit.de (Christoph H.)
    ; Related .......: _GetInstalledBrowser()
    ; Link ..........: http://www.autoitscript.com/forum/topic/14…bkeys-function/
    ; ===============================================================================================================================
    Func _GetDefaultBrowser()
    If @CPUArch = "X86" Then
    $sUserDefaultBrowserX86 = RegRead($REG_X86_HKCU_DB,"")
    If @error Then
    Return 0
    Else
    $asInstalledBrowserX86 = _GetRegSubKeys($REG_X86_HKLM_IB)
    $iIndexOfDB = _ArraySearch($asInstalledBrowserX86,$sUserDefaultBrowserX86)
    $sFullName = RegRead($REG_X86_HKLM_IB & "\" & $asInstalledBrowserX86[$iIndexOfDB],"")
    Return $sFullName
    EndIf
    ElseIf @CPUArch = "X64" Then
    $sUserDefaultBrowserX64 = RegRead($REG_X64_HKCU_DB,"")
    If @error Then
    Return 0
    Else
    $asInstalledBrowserX64 = _GetRegSubKeys($REG_X64_HKLM_IB)
    $iIndexOfDB = _ArraySearch($asInstalledBrowserX64,$sUserDefaultBrowserX64)
    $sFullName = RegRead($REG_X64_HKLM_IB & "\" & $asInstalledBrowserX64[$iIndexOfDB],"")
    Return $sFullName
    EndIf
    Else
    Return 0
    EndIf
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetInstalledBrowser
    ; Description ...: Returns an array with the names of installed browser.
    ; Syntax ........: _GetInstalledBrowser()
    ; Parameters ....: None
    ; Return values .: Success: Returns an array with the names of installed browsers (See remarks!).
    ; Failure: Returns 0
    ; Author ........: PainTain @ Autoit.de (Christoph H.)
    ; Remarks .......: Index 0 of the array contains the number of installed browsers.
    ; Related .......: _GetDefaultBrowser()
    ; Link ..........:
    ; ===============================================================================================================================
    Func _GetInstalledBrowser()
    If @CPUArch = "X86" Then
    Local $aListFullX86[2]

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

    $aInstalledBrowserX86 = _GetRegSubKeys($REG_X86_HKLM_IB)
    _ArrayAdd($aListFullX86,$aInstalledBrowserX86[0])
    For $i = 0 To UBound($aInstalledBrowserX86) - 1
    $sReadBrowserNameX86 = RegRead($REG_X86_HKLM_IB & "\" & $aInstalledBrowserX86[$i],"")
    _ArrayAdd($aListFullX86, $sReadBrowserNameX86)
    ReDim $aListFullX86[UBound($aListFullX86)]
    Next
    _ArrayDelete($aListFullX86, 0)
    _ArrayDelete($aListFullX86, 0)
    Return $aListFullX86
    ElseIf @CPUArch = "X64" Then
    Local $aListFullX64[2]

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

    $aInstalledBrowserX64 = _GetRegSubKeys($REG_X64_HKLM_IB)
    _ArrayAdd($aListFullX64,$aInstalledBrowserX64[0])
    For $i = 1 To UBound($aInstalledBrowserX64) - 1
    $sReadBrowserNameX64 = RegRead($REG_X64_HKLM_IB & "\" & $aInstalledBrowserX64[$i],"")
    _ArrayAdd($aListFullX64,$sReadBrowserNameX64)
    ReDim $aListFullX64[UBound($aListFullX64)]
    Next
    _ArrayDelete($aListFullX64, 0)
    _ArrayDelete($aListFullX64, 0)
    Return $aListFullX64
    Else
    Return 0
    EndIf
    EndFunc

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

    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetRegSubKeys
    ; Description ...: Returns an array with the sub keys of a given registry key.
    ; Syntax ........: _GetRegSubKeys($sHKEY)
    ; Parameters ....: $sHKEY - The registry key
    ; Return values .: Success: Returns an array with the Subkeys (See remarks!).
    ; Failure: Returns 0.
    ; Author ........: PainTain @ Autoit.de (Christoph H.)
    ; Remarks .......: Index 0 of the array contains the number of the read keys.
    ; Link ..........:
    ; ===============================================================================================================================
    Func _GetRegSubKeys($sHKEY)
    Local $i = 1
    Local $aSubKeys[$i]

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

    Do
    $sSubKey = RegEnumKey($sHKEY,$i)
    If @error Then Return 0
    ReDim $aSubKeys[UBound($aSubKeys)]
    _ArrayAdd($aSubKeys,$sSubKey)
    $i += 1
    Until RegEnumKey($sHKEY, $i) = "" And @error = "-1"
    _ArrayInsert($aSubKeys, 0, UBound($aSubKeys) - 1)
    _ArrayDelete($aSubKeys, 1)
    Return $aSubKeys
    EndFunc

    [/autoit]


    Beschreibung der 2 Funktionen steht in der UDF drinnen :)
    Ich werde beide Funktionen in den nächsten Tagen nochmal updaten, da sie noch nicht ganz fertig sind (vorallem _GetDefaultBrowser).


    Für diese UDF benötigte ich eine Funktion, um alle Unterschlüssel eines Regisrty-Schlüssels auszulesen.
    Nachdem BugFix's Variante nicht funktioniert hatte (RegFunc), schrieb ich mir meine eigene Funktion.
    Diese funktioniert (zumindest bei mir) ohne Probleme, also dachte ich mir, das ich diese hier auch gleich posten kann.

    BugFix möge mir es verzeihen, dass ich die Funktion genauso wie seine benannt habe :rolleyes:

    _GetRegSubKeys.au3
    [autoit]


    #include-once
    #include <Array.au3>

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

    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GetRegSubKeys
    ; Description ...: Returns an array with the sub keys of a given registry key.
    ; Syntax ........: _GetRegSubKeys($sHKEY)
    ; Parameters ....: $sHKEY - The registry key
    ; Return values .: Success: Returns an array with the Subkeys (See remarks!).
    ; Failure: Returns 0.
    ; Author ........: PainTain @ Autoit.de (Christoph H.)
    ; Remarks .......: Index 0 of the array contains the number of the read keys.
    ; Link ..........: http://www.autoitscript.com/forum/topic/14…bkeys-function/
    ; ===============================================================================================================================
    Func _GetRegSubKeys($sHKEY)
    Local $i = 1
    Local $aSubKeys[$i]

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

    Do
    $sSubKey = RegEnumKey($sHKEY,$i)
    If @error Then Return 0
    ReDim $aSubKeys[UBound($aSubKeys)]
    _ArrayAdd($aSubKeys,$sSubKey)
    $i += 1
    Until RegEnumKey($sHKEY, $i) = "" And @error = "-1"
    _ArrayInsert($aSubKeys, 0, UBound($aSubKeys) - 1)
    _ArrayDelete($aSubKeys, 1)
    Return $aSubKeys
    EndFunc

    [/autoit]

    Beide UDF's sind zudem nochmal in unten angehängt.
    Bei der "DefaultBrowser.au3" ist bereits die _GetRegSubKeys - Funktion drinnen ;)
    Wer (Rechtschreib-/Grammatik-) Fehler findet bitte ich mich darauf hinzuweisen.

    Falls noch jemand irgendeine ähnliche Funktion möchte, schreibt es :D

    Ansonst wünsche ich euch noch einen schönen Abend und vorallem

    Ein frohes Fest & neues Jahr euch allen :love:


    Mfg

    Edit: 6 Downloads und kein Feedback? ;(

    Dateien

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

    8 Mal editiert, zuletzt von PainTain (24. Dezember 2012 um 00:49) aus folgendem Grund: Update # 24.12.2012 // 00:47

  • #Update
    Die _GetDefaultBrowser Funktion sollte nun bei so ziemlich jedem Browser den vollen Namen anzeigen, solange er die Standart Registry-Einträge erstellt.

    Nun schau ich noch das die _GetInstalledBrowser Funktion komplett funktioniert :D

    Mfg

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski

  • Nur so... als Anmerkung.
    Es wird Standard geschrieben, nicht Standart. :whistling:
    Bin ja normalerweise nicht so kleinkarriert, aber du hast das im Titel. :D


    Danke für den Hinweis, habs ausgebessert ;)

    Ich war müde wie ich den Thread geschrieben hatte, da ich ne Nacht nicht geschlafen hatte :(

    Mfg

    There's a joke that C has the speed and efficieny of assembly language combined with readability of....assembly language. In other words, it's just a glorified assembly language. - Teh Interwebz

    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, you blow off your whole leg. - Bjarne Stroustrup
    Genie zu sein, bedeutet für mich, alles zu tun, was ich will. - Klaus Kinski