Logoff help in vs 2005
Hi I am new to vs 2005 and was wondering if anyone could help me with how to write a logoff script in a button control using vb. Any help would br great....Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Mar 29, 2007, 4:10 AM
This works fine with XP; I seem to recall some issues with forced logoffs in Vista but I would have to double check on my Vista machine. Here is a really short program defining a form class with a single button; the click event handler for the button calls for the logoff. The important parts are importing System.Runtime.InteropServices, writing the DLL Import statement, and the calling the method defined in the DLL import:
Here is the full text of the form class:
Imports
System.Runtime.InteropServicesPublic
Class Form1 ' The DLL ImportPrivate Declare Function ExitWindowsEx Lib "user32.DLL" _
(ByVal iFlag As Integer, ByVal iCause As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Call the DLL Imported Function - These args call for the logoff
ExitWindowsEx(0, 0)
End Sub
End Class