Server people 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's what's in 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!
This article only play a role, so that more VB programmers to develop components, procedures may exist problems, I hope the master to give correct corrections! Please contact me if you have any questions: webmaster@chinanetboy.com
Download Address: http://www.chinanetboy.com/code/detail.asp?id=142