Results 1 to 22 of 22

Thread: Log Off?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    32

    Log Off?

    How do you log off of Windows XP using VB.NET?



    josh
    Smartbar XP is WAY better then Dashboard. http://www.smartbarxp.com

  2. #2
    Junior Member
    Join Date
    Jan 2003
    Location
    Seattle, WA
    Posts
    17
    The ExitWindowsEx API Still works in .NET as far as I know.
    http://www.allapi.net/apilist/ExitWindowsEx.shtml

  3. #3
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    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?

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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!

    VB Code:
    1. shell"C:\WINDOWS\RUNDLL32.EXE user.exe,Exit,Windows"

  5. #5
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Originally posted by pirate
    Well , here's another way ......I've not tested it yet!

    VB Code:
    1. 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.

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    try this now .
    VB Code:
    1. Shell("C:\WINDOWS\system32\RUNDLL32.EXE user.exe,Exit,Windows")

  7. #7
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Originally posted by pirate
    try this now .
    VB Code:
    1. 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)

  8. #8
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Well it acutly dose do SOMETHING but it doesn't log off, the progress indicator just goes for a seconnd.

  9. #9
    Addicted Member
    Join Date
    Nov 2002
    Posts
    216
    this wouldnt happen to be for a virus or hack would it? it just sounds wierd if not what would you need that for?

  10. #10
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    the API Should still work...Make sure you changed the LONGS to Integers...
    VB Code:
    1. Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  11. #11
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    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.

  12. #12
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    How would you know if someone was logged on as you?
    Dont gain the world and lose your soul

  13. #13
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    I was going to use the filesystemwatcher.

  14. #14
    Addicted Member
    Join Date
    Nov 2002
    Posts
    216
    oh...

  15. #15
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Originally posted by sunburnt
    the API Should still work...Make sure you changed the LONGS to Integers...
    VB Code:
    1. 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.

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    here you go ... heavily tested on XP (more than 15 times )
    Attached Files Attached Files

  17. #17
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Thanks!

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 !

  19. #19

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    32
    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
    Smartbar XP is WAY better then Dashboard. http://www.smartbarxp.com

  20. #20
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    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.

  21. #21
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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

    VB Code:
    1. 'in a module
    2. Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
    3. Public Const EWX_LOGOFF As Short = 0
    4.  
    5. 'in your form
    6. Dim lresult As Object
    7. lresult = ExitWindowsEx(EWX_LOGOFF, 0)  'close all programs and log on as a different user

  22. #22
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    Thanks,
    It works now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width