Logoff windows session from VBA

A

AlexT

Folks

I'm trying to logoff the current Windows session from VBA.

I have looked into MSDN and came up with the following code

-----------------------------------------------------------------------

Private Const EWX_LogOff As Long = 0


Private Declare Function ExitWindowsEx Lib "user32" _
(ByVal dwOptions As Long, _
ByVal dwReserved As Long) As Long

Private Declare Function GetLastError Lib "kernel32" () As Long

Public Sub DOLogoff()

ExitWindowsEx (EWX_LogOff), &HFFFF
MsgBox "ExitWindowsEx's GetLastError " & GetLastError

End Sub

-----------------------------------------------------------------------

For some reason calling DOLogoff doesn't work, although
ExitWindowsEx returns 0 (no error ?)

Any idea ?

Regards

--alexT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top