?
Solved

Calling ExitWindows API

Posted on 1998-03-15
5
Medium Priority
?
316 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 200 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

Technology Partners: 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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

649 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