Basic Extension Framework

You can develop ISAPI extensions with any tool capable of building a 32-bit DLL. Microsoft® Visual C++® 5.0 includes the ISAPI Extension Wizard, a tool you can use to quickly establish the basic framework for an ISAPI extension. Most of the code shown in this topic is automatically generated by the ISAPI Extension Wizard.

ISAPI extensions can be thought of as having sections that correspond to the three basic functions:

Initialization

Initialization takes place through the entry point function GetServerVariable. In the C++ environment, you define entry point functions through a .def file. For example, the following code sample would be used to specify the entry point functions in a .def file for an extension called MyExtension.

; MyExtension.def : declares the module parameters for the DLL.
 
LIBRARY         "MyExtension"
 
EXPORTS
    HttpExtensionProc
    GetExtensionVersion
    TerminateExtension
 

The purpose of GetExtensionVersion is to establish the version of ISAPI that was used to build the DLL. The following code accomplishes this task.

BOOL WINAPI 
GetExtensionVersion(
    HSE_VERSION_INFO* pVer
    )
{
        pVer->dwExtensionersion = 
        MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
        strcpy(pVer->lpszExtensionDesc, "My ISAPI Extension");
 
return (TRUE);
}
 

Processing

You can expose your extension's functionality through the HTTPExtensionProc entry point function. This function receives an EXTENSION_CONTROL_BLOCK (ECB) structure that contains data used for required processing. Also, your extension communicates with IIS through the ECB.

You can obtain the ECB through the HttpExtensionProc function.

When you use HttpExtensionProc, it first sends a header to the client, which provides the client with information, such as the content type that will be returned. After you send the header, you can perform any other processing through the various callback functions provided in the ECB.

Further details on processing can be found in the Reading and Writing Asynchronously topic.

Termination

IIS removes an extension from memory when it is no longer needed. If the extension provides the optional TerminateExtension entry point function, IIS will call the function before removing the extension. You can use TerminateExtension to close down any threads that your extension has initialized during processing.


© 1997 by Microsoft Corporation. All rights reserved.