The server components included when you install IIS provide functionality to ASP scripts in powerful, easy-to-use packages. You could spend a lot of time and resources creating and implementing this functionality with ASP scripting alone.
You can access a component's functionality from within an ASP script in the same way, no matter which component you require. First, create an instance of the object using the appropriate and unique program ID of the component you want to instantiate. Once the instance is created, you can use references to the object to access any of the properties or methods provided by that component.
This example uses the Tools object of the Tools component, which you can use to accomplish a number of miscellaneous tasks, including form processing and file ownership management. The random number generation capabilities of the Tools object are demonstrated here.
The Server.CreateObject method is used to create an instance of the Tools object, using the program ID MSWC.Tools, and the variable example is set as an object reference to the new component instance. You access the desired method, Random in this case, by using the standard object.method format. Thus, each time this script is run, example.Random returns a random number between -32767 and 32767. This number is then sent to the client browser.
The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\simple\Components_VBScript.asp and ...\asp\simple\Components_JScript.asp.