Logon Screen Changer in VB.NET WPF

Initiotech
Posted by in WPF category on for Intermediate level | Views : 12685 red flag

This is an Application which can change your default Logon Screen of Windows XP. There are many applications that allow you to do this Application’s like Logon Studio etc.

I have developed this simple application in WPF using Vb.Net. You can see how i made it by following the description below. The Application does Not use any DLL’s nor does it use any API so it is very easy to understand.

MadXp’s Logon Screen Changer

This is an Application which can change your default Logon Screen of Windows XP. There are many applications that allow you to do this Application’s like Logon Studio etc.

I have developed this simple application in WPF using Vb.Net. You can see how i made it by following the description below. The Application does Not use any DLL’s nor does it use any API so it is very easy to understand.

Selecting The Logon Screen

The logon Screen is an Exe file so in the OpenFileDialog I Added a Filter that will only show EXE Files.

The below given code will Allow the OpenFileDialog to only show Exe Files and once a file is selected it will add that filename to a ListBox and also check that the File is not already present in the ListBox.

Private Sub Add_One(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim open As New OpenFileDialog()
open.Filter = "Logon Files(*.exe)|*.exe|All Files(*.*)|*.*"
If open.ShowDialog() = True Then
Dim fileName As String
fileName = open.FileName
Dim it As String = fileName.Remove(0, fileName.LastIndexOf("\") + 1)
If LogonList.Items.Contains(it) = False Then
LogonList.Items.Add(it)
path = open.FileName.Replace(it, "")
Button3.IsEnabled = True
Button2.IsEnabled = True
Else
MessageBox.Show(it & " Already Exist")
End If
Else
End If
End Sub

Changing the Image in the picture box to show preview of the seleted Logon Screen

The code below will allow you to see preview of the selected Logon Screen when the user selects it
from the ListBox.

Private Sub LogonList_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs)
Handles LogonList.SelectionChanged
Dim bmp As New BitmapImage()
Try
bmp.BeginInit()
bmp.StreamSource = New FileStream(path & LogonList.SelectedValue.ToString().Replace("exe", "jpg"), FileMode.Open)
Catch ex As Exception
bmp.StreamSource = New FileStream(Application.ResourceAssembly.Location.Replace("LogonChanger.exe", "Na.jpg"), FileMode.Open)
ErrMess.Content = "To get a Preview Save an .JPG Image with the Same Name as of the Logon in the Same Folder. Example:logon.exe must also have logon.jpg"
Finally
bmp.EndInit()
Image1.Source = bmp
Image1.UpdateLayout()
End Try
TextBox1.Text = path & LogonList.SelectedValue.ToString()
End Sub

Changing The Logn Screen

The Logon screen is changed using an Registry Entry in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT
CurrentVersion\Winlogon ====> UIHOST is the value that changes the Logon Screen

I have Written this code on the Apply Seleted Button

My.Computer.Registry.LocalMachine.OpenSubKey
("SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon", True).SetValue("UIHost", TextBox1.Text)

The TextBox1.Text holds the path to the selected Logon Screen

Restoring The Logon Screen To Default

Now it was very important to restore the logon screen back to Windows default in case you dont like the logon screens
So for setting the Logon Screen back to default i add This code to the Restore Back To Default button

My.Computer.Registry.LocalMachine.OpenSubKey
("SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon", True).SetValue("UIHost", "logonui.exe")

For testing how your Logon Screen Looks

Now it was very irritating for me to keep on logging off and seeing the Logon Screen So i used the Switch User Method.
Now you can also use this method in the form of an Button Click in VB.Net
For Switch Users and Quick Testing the Logon Screen i used this code on the TEST Button

Process.Start("rundll32.exe", "user32.dll,LockWorkStation")

The Following code was used to Switch Users Function.

Conclusion :

I tried my level best to make it simple for you to understand the logic behind this application.if you still face any difficulties please feel free to contact me.

Download The Full Project

Regards
Hefin Dsouza

Page copy protected against web site content infringement by Copyscape

About the Author

Initiotech
Full Name: Hefin Dsouza
Member Level: Starter
Member Status: Member
Member Since: 9/16/2009 12:32:23 PM
Country: India

http://hefin.in
My Name is Hefin Dsouza. I am a faculty at Computer Education Institute.I am also an Freelance Software Developer and Software Trainner.I am working with DotNet Technologies from the past 8 years.I am an Microsoft Certified Windows Application Developer for .NET 3.5. And also a Blogger at http://blog.hefin.in

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)