C ++ automatically restarts the computer

Source: Internet
Author: User

From: http://www.yuloo.com/jsjks/

 

How to restart and shut down the computer and log out

It mainly uses function calls in win32.

BOOL ExitWindowsEx (

UINT uFlags,

DWORD dwReason

);

First parameter close type

There are several types:

1. EWX_LOGOFF: Shut down all processes.

2. Power Off Of EWX_POWEROFF

3. Shut down and restart the system with EWX_REBOOT.

4. EWX_SHUTDOWN

The second parameter is related to the operating system.

Select

EWX_FORCE

Complete program:

# Include <Windows. h>

# Include <Winuser. h>

Int WinMain (HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPSTR lpCmdLine,

Int nCmdShow

)

{

ExitWindowsEx (EWX_LOGOFF, EWX_FORCE );

Return 0;

}

Connect User32.lib
Transferred from: <a href = 'HTTP: // www.yuloo.com/jsjks/'> Computer Training Network </a>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.