Posted By

FearTec on 07/29/13


Tagged

VBNet force Logoff InteropServices


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

D4RKCODE


Force Logoff in VB.NET via InteropServices


 / Published in: VB.NET
 

Force Logoff in VB.NET via InteropServices

  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  

You need to login to post a comment.