.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> WPF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Hefin's Logon Screen Changer in VB.NET WPF

Posted By:Hefin Dsouza       Posted Date: September 03, 2009    Points: 25    Category: WPF    URL: http://www.dotnetspark.com  
 

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

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend