Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 30017 |  Welcome, Guest!   Register  Login
Home > Articles > WPF > Logon Screen Changer in VB.NET WPF

Logon Screen Changer in VB.NET WPF

Article posted by Initiotech on 9/16/2009 | Views: 4812 | Category: WPF | Level: Intermediate 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

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Hefin Dsouza

Experience:8 year(s)
Home page:http://hefin.in
Member since:Wednesday, September 16, 2009
Level:Starter
Status: [Member]
Biography: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
>> Write Response - Respond to this post and get points
Related Posts

Events are not a new part to know about if you are working in Microsoft Technologies, but now when WPF has introduce a new concept called as Rounted Events, we will look into the same.

WPF added lot of flexibility and usability to the client application development. There are lots of features in WPF for enhancing the usability aspects of a client application. One of the interesting and very useful features is the WPF adorner. In this article we will discuss briefly about Adorner and how to create a simple adorner.

it's useful for beginners

In this article, I have specified how you could use Style, Triggers and animation in your WPF application to make your application more attractive, interactive and user friendly.

In this article I have showed how you can build pluggable Resources for styles, Languages or any static objects etc. Therefore building a new style doesn't hampers your code and you can easily plugin any new style to the application inspite it is already in production environment. I have added a language converter tool, which will generate multi lingual resources for you.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/28/2012 11:58:34 AM