How do you log off of Windows XP using VB.NET?
josh
Printable View
How do you log off of Windows XP using VB.NET?
josh
The ExitWindowsEx API Still works in .NET as far as I know.
http://www.allapi.net/apilist/ExitWindowsEx.shtml
Those examples don't seem to be working in vb.netQuote:
Originally posted by FireRabbit
The ExitWindowsEx API Still works in .NET as far as I know.
http://www.allapi.net/apilist/ExitWindowsEx.shtml
Does anyone know of any other examples?
Well , here's another way ......I've not tested it yet!Quote:
Originally posted by ProgrammerJon
Those examples don't seem to be working in vb.net
Does anyone know of any other examples?
VB Code:
shell"C:\WINDOWS\RUNDLL32.EXE user.exe,Exit,Windows"
when I tried running it I got a file not found error:Quote:
Originally posted by pirate
Well , here's another way ......I've not tested it yet!
VB Code:
shell"C:\WINDOWS\RUNDLL32.EXE user.exe,Exit,Windows"
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in microsoft.visualbasic.dll
Additional information: File not found.
try this now .
VB Code:
Shell("C:\WINDOWS\system32\RUNDLL32.EXE user.exe,Exit,Windows")
It dosn't do anything now.Quote:
Originally posted by pirate
try this now .
VB Code:
Shell("C:\WINDOWS\system32\RUNDLL32.EXE user.exe,Exit,Windows")
Note: I changed "C:\WINDOWS..." to "C:\WINNT" because WINNT is my system directory. (I have Windows 2000 pro)
Well it acutly dose do SOMETHING but it doesn't log off, the progress indicator just goes for a seconnd.
this wouldnt happen to be for a virus or hack would it? it just sounds wierd if not what would you need that for?
the API Should still work...Make sure you changed the LONGS to Integers...
VB Code:
Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
I was planning on writing a program that would log off my account if someone else was using it. The reason why I wanted a program for this is because I frequently leave my computer logged on to my user and my dad dosn't want other people on my login because I have higher security privalges then the other people who use this computer.Quote:
Originally posted by james14
this wouldnt happen to be for a virus or hack would it? it just sounds wierd if not what would you need that for?
How would you know if someone was logged on as you?
I was going to use the filesystemwatcher.
oh...
I don't undersand how to make this work, can you give me an example so that it will log off when you click a command button.Quote:
Originally posted by sunburnt
the API Should still work...Make sure you changed the LONGS to Integers...
VB Code:
Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
here you go ... heavily tested on XP (more than 15 times :( )
Thanks!
little note , it's better you run it from bin dir so it wouldn't ask you whether you want to stop debugging the code or not !Quote:
Originally posted by pirate
here you go ... heavily tested on XP (more than 15 times :( )
thanks a lot for all the help. THe changing the Long's to Integers fixed it. Thanks a lot. I will let you all know when my program is finished.
Josh
I worked great until I copied it an put it in my program.Quote:
Originally posted by pirate
here you go ... heavily tested on XP (more than 15 times :( )
it say's ExitWindowsEx and EWX_LOGOFF is not decleared.
do thisQuote:
Originally posted by ProgrammerJon
I worked great until I copied it an put it in my program.
it say's ExitWindowsEx and EWX_LOGOFF is not decleared.
VB Code:
'in a module Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer Public Const EWX_LOGOFF As Short = 0 'in your form Dim lresult As Object lresult = ExitWindowsEx(EWX_LOGOFF, 0) 'close all programs and log on as a different user
Thanks,
It works now.