We know that the direct use of ASP is not enough to restart the server, then we need to make a component to implement the function, ASP through this component calls the system API, and then according to different restart and shutdown mode to operate!
The following first said the production of COM, in VB, a new project, of course, is Aceivex DLL!
1) First modify the engineering properties, in the Project Properties window to change the project name to system, in the class Module window to change the module name to Contral, save the project;
2 and then add a module that declares the APIs and constants that need to be used! Here are the contents of the module!
Declare Function exitwindowsex Lib "user32" (ByVal uflags as Long, ByVal dwreserved as long) as long
3 Enter the following code in the class module:
Public Function reboot(atype As Variant)
t& = ExitWindowsEx(1, atype)
End Function
This function needs to pass in a parameter, used to control the startup mode, this parameter is passed from the ASP program, wait a moment to see the concrete use Method!
Write the above code, save the project, compile the project into System.dll. The following is to write ASP program!
The code in ASP is very simple:
<%
atype=request("atype")
set sys=server.CreateObject ("system.contral")
sys.reboot(atype)
%>
Where atype can use 0, 1, 2, 4,0, 1, and 4 to shut down, and 2 to reboot. After the completion of the implementation of ASP can be!