کد:
Option Explicit
Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function ExitWindowsEx _
Lib "user32" _
(ByVal uflags As Long, _
ByVal dwReserved As Long) As Long
Private Const EWX_Logoff = 0
Private Const EWX_Force = 4
Private lngNum As Long
Private Sub cmdLogoff_Click
ExitWindowsEx EWX_Logoff, ByVal 0&
End Sub