Force Logoff in VB.NET via InteropServices


/ Published in: VB.NET
Save to your folder(s)

Force Logoff in VB.NET via InteropServices


Copy this code and paste it in your HTML
  1. Imports System.Runtime.InteropServices
  2.  
  3. Public Class Form1
  4.  
  5. <Flags()> _
  6. Enum ExitWindows As UInteger
  7. LogOff = &H0
  8. ShutDown = &H1
  9. Reboot = &H2
  10. PowerOff = &H8
  11. RestartApps = &H40
  12. ' plus AT MOST ONE of the following two:
  13. Force = &H4
  14. ForceIfHung = &H10
  15. End Enum
  16.  
  17. Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Int32, ByVal dwReserved As Int32) As Int32
  18.  
  19. Private Sub ForceLogoffNow()
  20. Call ExitWindowsEx(ExitWindows.LogOff, ExitWindows.Force)
  21. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.