#cs ============================
Name: Win7 Logon-Bild Wechsler
Version: 2
Datum: 11.4.2010
Autor: Script-Bär
#ce ============================

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <skalieren.au3>
#include <WinAPI.au3>
#RequireAdmin
#NoTrayIcon

If @OSVersion <> "WIN_7" Then
    MsgBox(16, "Fehler", "Dein Betriebssystem ist nicht Windows 7.")
    Exit
EndIf
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $ExitID

_Main()

Func _Main()
    Local $createID, $DeleteID
    GUICreate("Custom Msgbox", 300, 80)
    GUICtrlCreateLabel("Bitte wählen sie eine Aktion aus.  ", 10, 10)
    GUICtrlCreateLabel("Aktueller Status: ", 10, 30)
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground") = 1 Then
        GUICtrlCreateLabel(">Benutzerdifiniert< ", 100, 30)
    Else
        GUICtrlCreateLabel(">Standart< ", 100, 30)
    EndIf
    $createID = GUICtrlCreateButton("Anmeldebildschirm verändern.", 10, 50)
    GUICtrlSetOnEvent($createID, "OnCreate")
    $DeleteID = GUICtrlCreateButton("Standart wiederherstellen.", 170, 50)
    GUICtrlSetOnEvent($DeleteID, "OnDelete")
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
    GUISetState()

    While 1
        Sleep(1000)
    WEnd
EndFunc   ;==>_Main

Func OnDelete()
    RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground")
    If @error = 0 Then
        MsgBox(16, "Fehler", "Registry-Wert konnte nicht gelöscht werden. Bitte manuell löschen." & @CRLF & "" & @CRLF & "Registry-Wert:" & @CRLF & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground")
    Else
        MsgBox(0, "Info", "Registry-Wert erfolgreich gelöscht.")
    EndIf
    MsgBox(48, "ACHTUNG!", "Nun wird ein Befehl ausgeführt der den selben effekt wie ein Neustart hat.")
    EnvUpdate()
EndFunc   ;==>OnDelete

Func OnExit()
    Exit
EndFunc   ;==>OnExit

Func OnCreate()
    Local $Bild, $BildL, $hGraphicsImg, $hBitMap, $hImage, $X, $y, $Ba, $BMa, $nB, $nH

    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground") <> 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "1")
        MsgBox(0, "Info", "Registry-Wert wurde erstellt")
        If @error <> 0 Then
            MsgBox(16, "Fehler", "Registry-Wert konnte nicht erstellt werden!")
        EndIf
    Else
        MsgBox(0, "Info", "Registry-Wert exsistiert berits!")
    EndIf

    If FileExists(@HomeDrive & "\Windows\System32\oobe\info\backgrounds") Then
        MsgBox(4096, "Info", "Erforderliches Verzeichnis existiert bereits.")
    Else
        DirCreate(@HomeDrive & "\Windows\System32\oobe\info\backgrounds")
        MsgBox(4096, "Info", "Erforderliches Verzeichnis wurde erstellt.")
    EndIf
	$Bild = FileOpenDialog("Bitte Bild auswählen.", "@DesktopDir", "JPG-Bild (*.jpg;*.JPG)", 1)
	GUICreate( "Ausgewähltes Bild" )
	GUICtrlCreatePic( $Bild, -1, -1 )
	GUISetState()
	$Ba = MsgBox(36, "Frage", "Ist dass ihr Bild?")
	If $Ba = 7 Then
		While $Ba <> 6
		$Bild = FileOpenDialog("Bitte Bild auswählen.", "@DesktopDir", "Bild (*.bmp)", 1)
		GUICreate( "title" )
		GUICtrlCreatePic( $Bild, -1, -1 )
		GUISetState()
		$Ba = MsgBox(36, "Frage", "Ist dass ihr Bild?")
		WEnd
	EndIf
	_GDIPlus_Startup()
	$BildL = _GDIPlus_ImageLoadFromFile($Bild)
    $X = _GDIPlus_ImageGetWidth($BildL)
    $y = _GDIPlus_ImageGetHeight($BildL)
	If $X <> @DesktopWidth Or $y <> @DesktopHeight Then
        MsgBox(16, "Fehler", "Die Bildgrösse entspricht nicht der Dektopauflösung")
		$BM = MsgBox(36, "Frage", "Wollen sie die Abmaße des Bildes ändern?")
	If $BMa = 6 Then
	   $nB = InputBox( "Frage", "Bitte geben sie die neue Breite des Bildes ein." )
	   $nH = InputBox( "Frage", "Bitte geben sie die neue Höhe des Bildes ein." )
   Else
	   Exit
    EndIf
    If FileGetSize($Bild) > 262144 Then
        MsgBox(16, "Fehler", "Bild ist zu groß (über 256 KB).")
        Exit
    EndIf
   $BMa = MsgBox(36, "Frage", "Wollen sie die Abmaße des Bildes ändern?")
   If $BMa = 6 Then
	   $nB = InputBox( "Frage", "Bitte geben sie die neue Breite des Bildes ein." )
	   $nH = InputBox( "Frage", "Bitte geben sie die neue Höhe des Bildes ein." )
   _ImageResize($Bild, @HomeDrive & "\Windows\System32\oobe\info\backgrounds\backgroundDefault.jpg", $nB, $nH)
   _GDIPlus_ImageDispose ($Bild)
  Else
   _GDIPlus_ImageDispose ($Bild)
   FileCopy($Bild, @HomeDrive & "\Windows\System32\oobe\info\backgrounds\backgroundDefault.jpg", 1)
   If @error <> 0 Then
	   MsgBox(16, "Fehler", "Bild kann nicht kopiert werden.")
	   EndIf
	EndIf
    EnvUpdate()
EndFunc   ;==>OnCreate