Terminate Windows 95 in Visual Basic

zhaozj2021-02-11  190

In the Visual Basic program, you can use the Windows API function to restart your computer.

System, text introduces how to exit Windows 95 and turn off the computer system.

# Turn off the computer system

You can use the Windows API's exitwindowsex function to come from the Visual Basic program.

Restart the computer system. To use this function, you need to contain the following statement statements in the form.

Usually declared in the section:

Private declare function exitwindowsex lib "user32" (ByVal

Uflags as long, byval dwreserved as long

The EXITWINDOWSEX function requires 2 parameters, you can use one or more below the identity

The combination tells the exitwindowsex function to want to perform a shutdown process.

EWX_FORCE All processes are mandatory to terminate.

EWX_LOGOFF All processes are forced to terminate and the user exits logged off.

The EWX_POWEROFF computer system is turned off and the computer is physically shut down if the power save feature is supported.

The EWX_REBOOT computer system is turned off and restarted.

The EWX_SHUTDOWN computer is physically safely shut down.

The combination of three identities above is used in the sample program. This identity combination

(EWX_LOGOFF, EWX_FORCE, and EWX_REBOOT "tells Windows95 to exit all positive

In the execution process, the user exits the network login, so that the computer system is ready to be available.

Household shutdown.

# 样 例 程序

The sample program shows how to turn off the computer system.

1. Start a new project in Visual Basic, establish FORM1 with the default approach.

2. Add the following constants and declaration statements to the usual declaration of Form1 (note the sound)

Ming list needs to be written in one line):

Private declare function exitwindowsex lib "user32" (ByVal

Uflags as long, byval dwreserved as long

Const EWX_LOGOFF = 0

Const ewx_shutdown = 1

Const EWX_REBOOT = 2

Const ewx_force = 4

Const ewx_poweroff = 8

Const EWX_RESET = EWX_LOGOFF EWX_FORCE EWX_Reboot

3. Add a command button control on Form1 to establish COMAND1 with the default method.

Set its CAPTION property to "Restart Computer".

4. Add the following code to Command1 Click on:

Private submmand1_click ()

DIM X as long

X = exitwindowsex (ewx_reset, dwreserved)

End Sub

Press F5 to run the above sample program, click the Command button to restart your computer system.

转载请注明原文地址:https://www.9cbs.com/read-4126.html

New Post(0)