ISAPI extensions can be thought of as having sections that correspond to the three basic functions:
Initialization takes place through the entry-point function GetExtensionVersion. 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
)
{
// Create the extension version string, and
// copy string to HSE_VERSION_INFO structure.
pVer->dwExtensionVersion =
MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
// Copy description string into HSE_VERSION_INFO structure.
strcpy(pVer->lpszExtensionDesc, "My ISAPI Extension");
return (TRUE);
}
In general, you expose your extension's functionality through the HttpExtensionProc entry-point function. This function receives a pointer to an EXTENSION_CONTROL_BLOCK structure that contains data used for the required processing. Also, your extension communicates with IIS through the EXTENSION_CONTROL_BLOCK.
You can obtain the EXTENSION_CONTROL_BLOCK through the HttpExtensionProc function.
When you use HttpExtensionProc, it should first send 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 EXTENSION_CONTROL_BLOCK.
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.