; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
#NoTrayIcon
#RequireAdmin
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1) ; Variablen müssen deklariert werden.
Opt('GUIOnEventMode', 1) ; Eventmode aktivieren.
AutoItSetOption ("GUICloseOnESC", 1) ; Wenn ESC gedrückt wird, Gui beenden.
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
Global $sInput1, $sstart, $nMsg, $sString
Global $sTitle = 'RegSearch'
Global $sVersion = '1.0.0.0'
Global $sAuthor = 'Bazii'
Global $sDate = '26.07.2017'
Global $sFound = ''
Global $hDLL = DllOpen("user32.dll")
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
If _Singleton ($sTitle, 1) = 0 Then    ; Wenn eine Instanz dieses Programms läuft, dann Meldung ausgeben ...
    MsgBox(64, "Achtung", " -RegSearch- wurde bereits gestartet und kann nicht ein zweites Mal gestartet werden!", 10) ; Meldung ausgeben (Teil 1)
    Exit ; Programm beenden
EndIf; Ende der If-Abfrage: Läuft bereits eine weitere Instanz?
; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +
GUICreate($sTitle & ' ' & $sVersion, 300, 90, -1, -1)
GUISetIcon("..\..\ICON\logo_FTP.ico", -1)
GUICtrlSetFont(-1, 9, 500, "Arial")
GUISetBkColor(0xD7E4F2)
GUISetOnEvent($GUI_EVENT_CLOSE, "__GUI_EVENT_CLOSE_")
$sInput1 = GUICtrlCreateInput("", 8, 8, 280, 21)
GUICtrlSendMsg(-1, 0x1501, 0, "HKLM Suchwort-Eingabe")
$sstart = GUICtrlCreateButton("Start!", 8, 56, 280, 25)
GUICtrlSetState($sstart, 768) ; Focus + Defbutton
GUICtrlSetOnEvent($sstart, _RegSearch_Start)
GUISetState(@SW_SHOW)
While Sleep(100)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd
Func _RegSearch_Start()
    Local $sString = GUICtrlRead($sInput1)
    Local $sfile = @ScriptDir & '\txt\' & $sString & '.txt'
    Local $sfile2 = @ScriptDir & '\reg\' & $sString & '.reg'
    If $sString = '' Then
        MsgBox(16,"Fehler","Bitte Suchwort eingeben")
        GUICtrlSetData($sString, "HKLM Suchwort-Eingabe")
        Return 0
    EndIf
    ToolTip('bitte warten...', @DesktopWidth / 1.8, @DesktopHeight / 2, 'Suche nach ' & $sString & ' ...', 1, 5)
    _RegSearch($sFound, 'HKEY_LOCAL_MACHINE', $sString)
    If _IsPressed("1B", $hDLL) Then
        MsgBox(64, "Achtung", "Abbruch durch Benutzer", 10)
        DllClose($hDLL)
        Exit
    EndIf
    FileOpen($sfile, 2)
    FileWrite($sfile, $sFound)
    FileClose ($sfile)
    FileOpen($sfile2, 2)
    FileWrite($sfile2, $sFound)
    FileClose ($sfile2)
;~     MsgBox(64, 'Hinweis', 'Registry erfolgreich ausgelesen', 10, $sfile)
    ShellExecute($sfile, @SW_MAXIMIZE)
    Exit
EndFunc ;==>_RegSearch1
Func _RegSearch(ByRef $sFound, $sRegPath, $sSearch) ; Funktion von Oscar
    Local $sKey, $sVal, $sVar, $i = 0, $j = 0
    While True
        $i += 1
        $sKey = RegEnumKey($sRegPath, $i)
        If @error Then ExitLoop
        _RegSearch($sFound, $sRegPath & '\' & $sKey, $sSearch)
        $j = 0
        While True
            $j += 1
            $sVal = RegEnumVal($sRegPath & '\' & $sKey, $j)
            If @error Then ExitLoop
            $sVar = RegRead($sRegPath & '\' & $sKey, $sVal)
            If StringInStr($sVar, $sSearch, 2) Then $sFound &= $sRegPath & '\' & $sKey & '\' & $sVal & @CRLF
        WEnd
    WEnd
    Return
EndFunc ;==>_RegSearch
Func __GUI_EVENT_CLOSE_()
    Exit
EndFunc ;==>__GUI_EVENT_CLOSE_