Microsoft KB Archive/271239

= SAMPLE: DLLList.exe Lists DLL Details with Binary Element Behavior =

Article ID: 271239

Article Last Modified on 3/29/2007

-

APPLIES TO


 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q271239



SUMMARY
DLLList.dll implements an Internet Explorer binary element behavior. Element behaviors are reusable components that act like custom Hypertext Markup Language (HTML) tags in a Web page and allow you to create powerful components that utilize HTML as their user interface.

DLLList.dll takes a list of dynamic-link libraries (DLLs) that is embedded in a Web page and displays version information for each DLL. If a DLL cannot be located in the DLL search path, the DLL is displayed in red strikethrough. DLLList.dll takes Extensible Markup Language (XML) as input and uses XML and an associated XSL style sheet (supplied by the component's user) to format the results.

This article includes the following sections:
 * Install DLLList
 * Run DLLList
 * DLLList Details



Install DLLList
The following file is available for download from the Microsoft Download Center:

DLLList.exe

Release Date: January 9, 2001

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Run DLLList
 Compile the application under Microsoft Visual C++ 6.0. Make sure that you download the Internet Explorer 5.5 headers and libraries and that they are placed in the Include search path. The Internet Explorer 5.5 headers and libraries are part of the current Platform Software Development Kit (SDK), which you can download from the Microsoft Download Center:

http://msdn.microsoft.com/downloads/

 Place the DllDisplayFormat.xsl and Test.htm files in the same folder on a Web server.

NOTE: The XSL file does not load properly if you try to run this sample from the filesystem. In Internet Explorer 5.5, launch the Test.htm page that is included with the project.

DLLList Details
DLLList demonstrates the following aspects of element behaviors:
 * Required interfaces for an element behavior
 * Passing data as literal content
 * Passing data as tag attributes
 * Incorporating a Viewlink
 * Using XSL to separate display and functionality

Required Interfaces for an Element Behavior
The following interfaces are required for an element behavior: IObjectWithSite, IElementBehavior, IElementBehaviorFactory, and IElementNamespaceFactory. DLLList implements these interfaces. For more information on the implementation of these interfaces, see the following Microsoft Developer Network (MSDN) Web site:

How to Create a Binary Element Behavior Using ATL

http://msdn.microsoft.com/workshop/browser/behaviors/howto/belementb.asp

Passing Data as Literal Content
Element behaviors are used on a page like HTML tags. An element behavior can activate literal content to tell Internet Explorer not to parse anything between the behavior's opening and closing tags, but to pass this content directly to the element behavior for parsing. This feature is activated inside the behavior's implementation of the IElementNamespaceFactory::Create method, where the IElementNamespace::AddTag method is called with the ELEMENTDESCRIPTORFLAGS_LITERAL parameter as follows: STDMETHODIMP CDllList::Create(IElementNamespace *pNamespace) { HRESULT hr = S_OK;

BSTR tagName = ::SysAllocString(L&quot;DllList&quot;); hr = pNamespace->AddTag(tagName, ELEMENTDESCRIPTORFLAGS_LITERAL); ::SysFreeString(tagName);

return hr; } Literal content, when used in conjunction with XML, is an excellent way to pass non-scalar parameters to an element behavior. In Test.htm, the component is instantiated as follows: 

 shdocvw.dll</Dll> <Dll>mshtml.dll</Dll> <Dll>wininet.dll</Dll> <Dll>ahjskja.ocx</Dll> <Dll>urlmon.dll</Dll> <Dll>comctl32.ocx</Dll> <Dll>comcat.dll</Dll> </DllList>

</CustomComponents:DllList> Everything between the <CustomComponents:DllList> tags is actually a small XML file, which is loaded into an instance of the Microsoft XML Parser (MSXML) in the CDllList::AddVersionDataXML method. Then the behavior uses XML interfaces to iterate through the list of <Dll> tags and extract each DLL name one at a time so that CDllList::AddVersionData can look up the version information.

Passing Data as Tag Attributes
Look at our <CustomComponent:DllList> tag again: it contains a series of custom attributes that specify various scalar parameters for the behavior. Whenever Internet Explorer notices attributes on the tag of a binary element behavior, it queries the behavior for the IPersistPropertyBag interface and calls the Load method (just as Internet Explorer does for ActiveX controls and <PARAM> tags). This allows the behavior to initialize publicly exposed properties.

Incorporating a Viewlink
Element Behaviors can choose to incorporate a Viewlink, which is an HTML document that acts as the visible representation of the control. Viewlinks have many advantages, including globalization, which uses Element Behaviors to allow Web developers to use Internet Explorer's excellent globalization support to display text in almost any language.

DLLList loads a very simple Viewlink named Template.htm, which contains an empty DIV element. DLLList uses the new IHTMLDocument4::createDocumentFromUrl method to load this document in CDllList::Notify. After it has a valid document pointer, it can get a reference to the component's IHTMLElementDefaults interface from the component's site (specifically, from the IElementBehaviorSiteOM2 interface) and call the putref_viewLink method to set the Viewlink.

All documents that are loaded by MSHTML load asynchronously, including the documents that are returned by createDocumentFromUrl. To prevent the element behavior from accessing elements in its Viewlink before the Viewlink has fully loaded, you can call the Viewlink's IHTMLDocument2::get_parentWindow method and call the IHTMLWindow2::put_onload method to pass the IDispatch interface of COnLoadHandler. COnLoadHandler waits for a DISPID of 0 (the DISPID that is used by all of the IHTMLDocument2::put_* methods to indicate that the event has been fired by Internet Explorer) and then calls a method on a private callback interface that is defined on our behavior's main class, CDllList. This callback, IDllListCallback::CompleteStartup, can then call the methods that populate the empty DIV on the Viewlink with a list of DLLs and their versions.

Using XSL to Separate Display and Functionality
How do you call out the code that is used to display custom data inside the Viewlink so that you can change the appearance of the data without having to recompile the element behavior? This is one of the hardest practical questions to answer when you write a binary element behavior. Once again, you can use XML to resolve this.

When the IDllListCallback::CompleteStartup function is called, it calls another function, CDllList::AddVersionDataXML, which iterates through the list of DLLs that is provided in the literal content and, in conjunction with CDllList::AddVersionData, creates another XML file in the following format: <DllList>

<Dll Name=&quot;shdocvw.dll&quot; Debug=&quot;Yes&quot; PrivateBuild=&quot;Yes&quot;> <FileVersion>5.50.4936.0400</FileVersion> <ProductVersion>5.50.4936.0400</ProductVersion> <FileType>DLL</FileType> </Dll>

...

</DllList> This XML file is used in conjunction with the XSL argument of the <CustomComponent:DllList> HTML tag to perform a transformNode on this XML file, which results in formatted HTML that can be assigned to the empty DIV inside our Viewlink. Therefore, to change the appearance of the DLL version data, you only have to change the XSL file that is used in the transform; you do not have to recompile the component.

<div class="references_section">