This project is read-only.

How to use this program


  • To change the LogonUI background
- Run the program
- Click the "..." button to select a JPG image file (smaller than 250 KB)
- Click the "Apply new background image" button to change the LogonUI background
  • To restore the original LogonUI background
- Run the program
- Click the "Restore original background image" button to restore the original LogonUI background


------------------------------------------------------------------------------------------------

How to change the LogonUI background manually

- Open Registry Editor
- Go to this key: HKEY-LOCAL-MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background
- Select the value OEMBackground, then change the value data to 1
- Make a new folder: \WINDOWS\system32\oobe\info\backgrounds
- Copy the JPG image file to the folder, then rename it to backgroundDefault.jpg

How to restore the LogonUI background manually

- Open Registry Editor
- Go to this key: HKEY-LOCAL-MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background
- Select the value OEMBackground, then change the value data to 0
- Delete this folder: \WINDOWS\system32\oobe\info

------------------------------------------------------------------------------------------------

Main code

The main subroutines are Apply() and Restore()

Imports System.IO
Imports Microsoft.Win32

Public Class frmMain
     Dim bgfile, systemdir As String


     Sub Apply()
          Try
               bgfile = txtBGFile.Text
               If bgfile = "" Then
                    MsgBox("You have not selected a JPG image file", MsgBoxStyle.Information, "Error")
                    Exit Sub
               End If
               Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", 1, Microsoft.Win32.RegistryValueKind.DWord)
               If Not Directory.Exists(systemdir + "\oobe\info") Then
                    Directory.CreateDirectory(systemdir + "\oobe\info")
                    Directory.CreateDirectory(systemdir + "\oobe\info\backgrounds")
               Else
                    If Not Directory.Exists(systemdir + "\oobe\info\backgrounds") Then
                         Directory.CreateDirectory(systemdir + "\oobe\info\backgrounds")
                    End If
               End If

               File.Copy(bgfile, systemdir + "\oobe\info\backgrounds\backgroundDefault.jpg", True)

               MsgBox("LogonUI background changed successfully", MsgBoxStyle.OkOnly, "Successfully")
          Catch ex As Exception
               MsgBox("Failed" + vbCrLf + ex.Message, MsgBoxStyle.Exclamation, "Failed")
               Restore()
          End Try
     End Sub

     Sub Restore()
          Try
               Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", 0, Microsoft.Win32.RegistryValueKind.DWord)
               If Directory.Exists(systemdir + "\oobe\info") Then
                    Directory.Delete(systemdir + "\oobe\info", True)
               End If

               MsgBox("LogonUI background restored successfully", MsgBoxStyle.OkOnly, "Successfully")
          Catch ex As Exception
               MsgBox("Restore failed" + vbCrLf + ex.Message, MsgBoxStyle.Exclamation, "Restore failed")
          End Try
     End Sub

     Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
          dlgOpen.ShowDialog()
     End Sub

     Private Sub dlgOpen_FileOk(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles dlgOpen.FileOk
          bgfile = dlgOpen.FileName
          'Check
          Dim inf As New FileInfo(bgfile)

          If Not inf.Exists Then
               MsgBox("File does not exist", MsgBoxStyle.Information, "Error")
               GoTo wrong
          End If

          If inf.Extension <> ".jpg" Then
               MsgBox("This is not a JPG image file", MsgBoxStyle.Information, "Error")
               GoTo wrong
          End If


          If inf.Length > 256000 Then
               MsgBox("The file size is bigger than 250 KB", MsgBoxStyle.Information, "Error")
               GoTo wrong
          End If

          'Set
          txtBGFile.Text = bgfile
          Exit Sub
wrong:
          bgfile = ""
          txtBGFile.Text = ""
          Exit Sub
     End Sub

     Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click
          Apply()
     End Sub

     Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          If My.Computer.Info.OSFullName.IndexOf("Windows 7", StringComparison.CurrentCultureIgnoreCase) = -1 Then
               MsgBox("This program must be run in Windows 7", MsgBoxStyle.Information, "Error")
               End
          End If
          systemdir = Environment.GetEnvironmentVariable("windir") + "\system32"
     End Sub

     Private Sub btnRestore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestore.Click
          Restore()
     End Sub

     Private Sub btnAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbout.Click
          AboutBox.ShowDialog()
     End Sub
End Class

Last edited Dec 2, 2009 at 5:43 AM by chilinhhacker, version 4

Comments

No comments yet.