Click to See Complete Forum and Search --> : Log Off?
pylesj
Jan 30th, 2003, 07:13 PM
How do you log off of Windows XP using VB.NET?
josh
FireRabbit
Jan 30th, 2003, 11:00 PM
The ExitWindowsEx API Still works in .NET as far as I know.
http://www.allapi.net/apilist/ExitWindowsEx.shtml
ProgrammerJon
Jan 31st, 2003, 07:20 PM
Originally posted by FireRabbit
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.net
Does anyone know of any other examples?
Pirate
Jan 31st, 2003, 08:04 PM
Originally posted by ProgrammerJon
Those examples don't seem to be working in vb.net
Does anyone know of any other examples?
Well , here's another way ......I've not tested it yet!
shell"C:\WINDOWS\RUNDLL32.EXE user.exe,Exit,Windows"
ProgrammerJon
Feb 1st, 2003, 09:31 AM
Originally posted by pirate
Well , here's another way ......I've not tested it yet!
shell"C:\WINDOWS\RUNDLL32.EXE user.exe,Exit,Windows"
when I tried running it I got a file not found error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in microsoft.visualbasic.dll
Additional information: File not found.
Pirate
Feb 1st, 2003, 10:06 AM
try this now .
Shell("C:\WINDOWS\system32\RUNDLL32.EXE user.exe,Exit,Windows")
ProgrammerJon
Feb 1st, 2003, 10:28 AM
Originally posted by pirate
try this now .
Shell("C:\WINDOWS\system32\RUNDLL32.EXE user.exe,Exit,Windows")
It dosn't do anything now.
Note: I changed "C:\WINDOWS..." to "C:\WINNT" because WINNT is my system directory. (I have Windows 2000 pro)
ProgrammerJon
Feb 1st, 2003, 10:30 AM
Well it acutly dose do SOMETHING but it doesn't log off, the progress indicator just goes for a seconnd.
james14
Feb 1st, 2003, 10:43 AM
this wouldnt happen to be for a virus or hack would it? it just sounds wierd if not what would you need that for?
sunburnt
Feb 1st, 2003, 11:57 AM
the API Should still work...Make sure you changed the LONGS to Integers...
Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
ProgrammerJon
Feb 1st, 2003, 02:46 PM
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?
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.
DevGrp
Feb 1st, 2003, 03:00 PM
How would you know if someone was logged on as you?
ProgrammerJon
Feb 1st, 2003, 03:04 PM
I was going to use the filesystemwatcher.
james14
Feb 1st, 2003, 05:25 PM
oh...
ProgrammerJon
Feb 1st, 2003, 08:52 PM
Originally posted by sunburnt
the API Should still work...Make sure you changed the LONGS to Integers...
Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
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.
Pirate
Feb 1st, 2003, 09:07 PM
here you go ... heavily tested on XP (more than 15 times :( )
ProgrammerJon
Feb 1st, 2003, 09:14 PM
Thanks!
Pirate
Feb 1st, 2003, 09:14 PM
Originally posted by pirate
here you go ... heavily tested on XP (more than 15 times :( )
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 !
pylesj
Feb 1st, 2003, 10:51 PM
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
ProgrammerJon
Feb 2nd, 2003, 10:30 AM
Originally posted by pirate
here you go ... heavily tested on XP (more than 15 times :( )
I worked great until I copied it an put it in my program.
it say's ExitWindowsEx and EWX_LOGOFF is not decleared.
Pirate
Feb 2nd, 2003, 11:32 AM
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.
do this
'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
ProgrammerJon
Feb 2nd, 2003, 11:37 AM
Thanks,
It works now.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.