Solved

Calling ExitWindows API

Posted on 1998-03-15
5
306 Views
Last Modified: 2008-03-06
I'm trying to write a simple login program, which should probably act in the normal way:
1. User logs on
2. If the ID or password is wrong, prompt the user to key in again
3. After 3 tries (or if the user clicks on Cancel), i call the ExitWindows API and get out of Windows and shut down the PC.

The declaration in General/Declaration is:
Private Declare Function ExitWindows Lib "user32" (ByVal dwReserved As Long, ByVal uReturnCode As Long) As Long

The problem is, i don't know what parameters to put in the ExitWindows function.

Can someone help me?  Thanks!!

daphne
0
Comment
Question by:daphne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 50 total points
ID: 1459134
daphne,
here is my routine, you can just put it in a module, and call it.
Good luck, and best wishes.
Dalin


Const EWX_LOGOFF = 0
Const EWX_REBOOT = 2
Const EWX_SHUTDOWN = 1


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

Sub sShutdownWindow()
ExitWindowsEx EWX_REBOOT, 0
End Sub


0
 
LVL 8

Expert Comment

by:mrmick
ID: 1459135
daphne, when you ask a question, you should provide as many details as you can.  At least specify the version of VB and the target OS for the app.  I suspect you're writing this app for NT; if this is the case, the ExitWindows function will not be enough to shut down (or reboot) the computer.

0
 

Author Comment

by:daphne
ID: 1459136
mrmick: oops... sorry... didn't realize that details like that are important.  i'm writing this for Win95 using VB5.0.

Dalin: what's the difference between ExitWindowsEx and ExitWindows?
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1459137
daphne, I have not used the ExitWindow function. My understanding on the difference between the two:

ExitWindows() close down any user application and logoff the current user, and leave the machine at the logon screen. It is a micro to call the the ExitWindowEx(0 function using the logoff option. The two parameters are reserved and must be zero.

The ExitWindowEx() is the function doing the actual work.  You can specify whether you wanted to leave it in the login screen like the ExitWindow() does, or Restart the system, or power off.

Regards.
0
 

Author Comment

by:daphne
ID: 1459138
Thanks so much, Dalin!  :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question