Microsoft KB Archive/224980

= Using Scriptlets as COM Components in ASP =

Article ID: 224980

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q224980



SUMMARY
Microsoft Windows Script Components allow developers to write COM components, known as Scriptlets, in languages such as VBScript or JavaScript. These components can then be called from any COM-compliant programming environment, such as Microsoft Visual C++, Visual Basic, or Active Server Pages (ASP).



MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

The following example shows how to create and register a sample scriptlet on your system and then call it from ASP.   Copy the following code and save it as "Example.sct" on your desktop:   

        </METHOD> </IMPLEMENTS>

<SCRIPT LANGUAGE="VBScript"> Option Explicit Function CreateButton(txt,url,fore,back,glow,width) Dim strNormal Dim strGlow strNormal = "this.style.background='" & back & "';" strGlow  = "this.style.background='" & glow & "';"

CreateButton = vbCrLf & " " & vbCrLf End Function </SCRIPT> </SCRIPTLET> Notes: <ul> <li>The ProgID field in the Registration section refers to the scriptlet's Class ID.</li> <li>After registering the scriptlet, an entry for the class ProgID and CLSID are created in the registry at the following locations:

<pre class="fixed_text">HKEY_CLASSES_ROOT\DHTML.Button.Scriptlet HKEY_CLASSES_ROOT\DHTML.Button.Scriptlet\CLSID

</li> <li>Using the CLSID default value, you can obtain the class GUID, which can be used to build the path to the following two keys:

<pre class="fixed_text">HKEY_CLASSES_ROOT\CLSID\{class GUID goes here}\InprocServer32 HKEY_CLASSES_ROOT\CLSID\{class GUID goes here}\ScriptletURL

</li> <li>These two keys can be especially useful in obtaining the following troubleshooting information:

InprocServer32 = The path to the handler DLL (for example Scrobj.dll)

ScriptletURL = The path to the scriptlet

</li></ul> </li> <li>Right-click on the scriptlet and select Register, and then click OK for the confirmation dialog.</li> <li> Save the following ASP code as "Example.asp" in a Web folder on your IIS computer with Script Access enabled: <%@LANGUAGE="VBSCRIPT"%> <% Option Explicit %>

<% Dim objButton

Set objButton = Server.CreateObject("DHTML.Button.Scriptlet")

Response.Write objButton.CreateButton("Back to Home","/","white","black","#0000ff","100") Response.Write objButton.CreateButton("Microsoft","http://www.microsoft.com","#ff ff00","magenta","#33cc33","100") Response.Write objButton.CreateButton("MSDN","http://msdn.microsoft.com","black", "red","brown","100") %>                       </li> <li>When you browse the example page, you should see three DHTML hover buttons.</li></ol>

For more information, please see the Microsoft Scripting Technologies Web site.

Keywords: kbcodesnippet kbinfo KB224980

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.