• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

How to shut off the coputer

How do I turn off the computer.  I am guessing that is just closing explorer,  but I just want tobe sure.
0
manly9004
Asked:
manly9004
1 Solution
 
syleshCommented:
'Hi
'Next time when u ask question Explain
'question more brief ,
'To shut down using From VB this is code.



Option Explicit
    ' Constants used by Windows API:
    Const EWX_SHUTDOWN As Long = 1
    Const EWX_POWEROFF As Long = 8
    Const API_ERROR As Long = 0

    ' Declare API Functions:
    Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, _
                                             ByVal dwReserved As Long) As Long

Private Sub Form_Load()
    ' Call shutdown function. Power off if possible.

    Dim lResult As Long

    lResult = ExitWindowsEx((EWX_SHUTDOWN Or EWX_POWEROFF), 0)
    If lResult = API_ERROR Then
        MsgBox "Error! Can't shut down Windows.", vbExclamation
    Else
        Unload Me
    End If
End Sub
0
 
master01Commented:
I assume that you mean shut down windows.

Put this in a module:
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

put this wherever you want to shut windows down.
VARIABLE = ExitWindowsEx(1, 1)
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now