Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to create a "logout" form

Status
Not open for further replies.

CaptainD

Programmer
Jul 13, 1999
644
US
I want to create a small form with a command button that logs a user out of Win98. I have User profiles in Win98 but anyone that clicks cancel now has access to the computer. What I want to do is put a small program in Startup that you have to click to clear, once clicked it logs you out. I've tried Sendkeys "%{f4}" and variations but it's not working. ((Alt F4) at the desktop does work) What am I doing wrong? Seems like a simple problem but so far nothing has worked.
 
Put the following code in a general section of a module:

Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long, _
ByVal dwReserved As Long)
Public Const EWX_FORCE = 4
Public Const EWX_LOGOFF = 0
Public Const EWX_REBOOT = 2
Public Const EWX_SHUTDOWN = 1

Put the following code in your command this form is the start-up object onclick:

Call ExitWindowsEx(EWX_LOGOFF, 0)
Unload Me

You realize someone can use ctrl + escape to open the start menu if you need to know how to disable that you can ask me, I posted a good answered question about that but cannot find it now.

The border style of the form also needs to be 0 – none and on opening the form (form load event) you should maximise the form so nobody can click on any items of the desktop see code below:

Private Sub Form_Load()
Form1.WindowState = 2
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top