I'm trying to make a login in screen for windows because I don't like the current one. I want to know how to log off the current user and how to make it log back on! Any type of help concerning this subject is appreciated!!!
Printable View
I'm trying to make a login in screen for windows because I don't like the current one. I want to know how to log off the current user and how to make it log back on! Any type of help concerning this subject is appreciated!!!
To log off, use the ExitWindowsEx api function:
Code:Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
EWX_FORCE = 4
EWX_LOGOFF = 0
Private Sub Command1_Click()
Dim retval As Long
retval = ExitWindowsEx(EWX_FORCE Or EWX_FORCE, 0)
If retval = 0 Then Debug.Print "Log off attempt failed."
End Sub
And to log back on, you'd have to still use the main log on Windows, but I suppose you could use SendKeys to do it.
SendKeys wont work. Once you log off, your app will close.