Switch windows in an application

Source: Internet
Author: User

In actual applications, some system settings have been modified and windows must be restarted.

After a software program, you must Disable Windows. During the demonstration, you are prohibited from forcibly disabling windows.

To solve the above problems, I have compiled a program to comprehensively solve the above problems.

  1. Implementation principle:

    1. restart Windows, shut down Windows, and end the current user process by calling

    Implemented by the exitwindowsex function. This function has two parameters. The previous parameter is represented by ewx_force.

    Forcibly shut down Windows without reminding you to save the running results of other applications. The next parameter is ewx_logoff.

    Indicates that the current user process is logged out; ewx_shutdown indicates that Windows is disabled; ewx_reboot indicates that

    Restart Windows.

    2. Disabling windows is disabled. When Windows 98 is disabled, the system sends

    The message wm_queryendsession notifies each application to shut down. If the returned message value is 0, it cannot

    Disable Windows98.

    Figure 1

  2. Application instance:

  1. Create a form containing the following controls:

Control name Caption

Form form1 restarts windows

Check box checkbox1 to force end the current user process

Check box checkbox2 Force Shutdown

Check box checkbox3 force restart the machine

Check box checkbox4 disable Shutdown

Check box checkbox5 exit

2. program list:

Unit clsw;

Interface

Uses

Windows, messages, sysutils, classes, graphics, controls, forms, dialogs,

Stdctrls;

Type

Tform1 = Class (tform)

Checkbox1: tcheckbox;

Checkbox2: tcheckbox;

Checkbox3: tcheckbox;

Checkbox4: tcheckbox;

Checkbox5: tcheckbox;

Procedure checkbox1click (Sender: tobject );

Procedure checkbox2click (Sender: tobject );

Procedure checkbox3click (Sender: tobject );

Procedure checkbox5click (Sender: tobject );

Private

Procedure wmqueryendsession (var msg: tmessage );

Message wm_queryendsession;

{Private Declarations}

Public

{Public declarations}

End;

VaR

Form1: tform1;

Implementation

{$ R *. DFM}

Procedure tform1.checkbox1click (Sender: tobject );

VaR ewx_logoff, ewx_force: integer;

Begin

Ewx_logoff: = 0;

Ewx_force: = 4;

Exitwindowsex (ewx_force or ewx_logoff, 0 );

End;

Procedure tform1.checkbox2click (Sender: tobject );

VaR ewx_shutdown, ewx_force: integer;

Begin

Ewx_shutdown: = 1;

Ewx_force: = 4;

Exitwindowsex (ewx_force or ewx_shutdown, 0 );

End;

Procedure tform1.checkbox3click (Sender: tobject );

VaR ewx_reboot, ewx_force: integer;

Begin

Ewx_reboot: = 2;

Ewx_force: = 4;

Exitwindowsex (ewx_force or ewx_reboot, 0 );

End;

Procedure tform1.wmqueryendsession (var msg: tmessage );

Begin

If checkbox4.checked then

MSG. Result: = 1

Else

MSG. Result: = 0;

End;

Procedure tform1.checkbox5click (Sender: tobject );

Begin

Close;

End;

End.

The above programs run in Windows 98 and dephi 4.0.

Related Article

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.