Recently, I often went to the Forum and hung up. It seems that the IIS process occupies too much system resources. The server administrator went over the weekend and couldn't restart IIS. It was depressing. The iis of the csdn server may be restarted too frequently, and the sub-forum pages are often too late to be updated. The posts posted by myself are sunk when they appear in the list, and they are still depressed.
Microsoft Knowledge Base Article q194916 restarting Web Services and scheduled tasks with a batch file (http://support.microsoft.com /? Kbid = 194916) describes how to regularly restart IIS using command lines. If you want to be lazy, try it. SC .exe with tools included in platform sdkallows you to configure the service in more detail.
If you use a program to restart IIS, you can use the servicestop and servicestart methods of the ishelldispatch2 interface of the shell object. To use the shell object, you can call cocreateinstance and pass the CLSID clsid_shell of the shell object to create the object, and then query its ishelldispatch/ishelldispatch2 and Other interfaces for further operations.
In addition, WMI win32_applicationservice also provides methods to control services: startservice and stopservice. Cideguru has an example above Using WMI to extract Management Information (http://www.codeguru.com/Cpp/W-P/system/misc/article.php/c5675 ). The advantage of WMI is that it can be remotely managed; the disadvantage is that it is difficult to configure.
Of course, you can use Windows Service APIs. Although openservice is required, controlservice and startservice are not very simple. The sample sending control requests to a service (http://msdn.microsoft.com/library/en-us/dllproc/base/sending_control_requests_to_a_service.asp) in the Platform SDK describes this. Use Windows Services apichangeserviceconfig and changeserviceconfig2 to configure the service in more detail.
These methods can be applied to other services. To query the short name of a service, refer to the Microsoft Knowledge Base Article q271362 how to find the short names of services (http://support.microsoft.com /? Kbid = 271362)
References
Browse for a folder the com way (Visual C ++ developer, Aug. 1999)
More Windows 2000 UI goodies: extending explorer views by customizing hypertext template files (http://msdn.microsoft.com/msdnmag/issues/0600/w2kui2/default.aspx)