home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************/
- //
- // File: Simple.cpp
- //
- // Description: Simple ISAPI Extension Example
- //
- // Functions: DllMain
- // GetExtensionVersion
- // WriteString
- // HttpExtensionProc
- //
- /*********************************************************************/
-
-
- #define _WIN32_WINNT 0x400
-
-
- #include <windows.h>
- #include <httpext.h>
-
-
- /*********************************************************************/
- //
- // Function: DllMain
- //
- // Description: The initialization function for this DLL.
- //
- /*********************************************************************/
-
-
- BOOL WINAPI DllMain( IN HINSTANCE hinstDll,
- IN DWORD dwReason,
- IN LPVOID lpvContext OPTIONAL )
- {
- // Note that appropriate initialization and termination code
- // would be written within the switch statement below. Because
- // this example is very simple, none is currently needed.
-
- switch(dwReason)
- {
- case DLL_PROCESS_ATTACH:
- break;
-
- case DLL_PROCESS_DETACH:
- break;
- }
-
- return(TRUE);
- }
-
-
- /*********************************************************************/
- //
- // Function: GetExtensionVersion
- //
- // Description: The first function called after IIS successfully
- // loads the DLL. The function should use the
- // version structure provided by IIS to set the ISAPI
- // architectural version number of this extension.
- //
- // A simple text-string is also set so that
- // administrators can identify the DLL.
- //
- // Note that HSE_VERSION_MINOR and HSE_VERSION_MAJOR
- // are constants defined in httpext.h.
- //
- /*********************************************************************/
-
-
- BOOL WINAPI GetExtensionVersion( HSE_VERSION_INFO * pVersion )
- {
- pVersion->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
- HSE_VERSION_MAJOR );
-
- strcpy( pVersion->lpszExtensionDesc,
- "IIS SDK Simple ISAPI Extension" );
-
- return(TRUE);
- }
-
-
- /*********************************************************************/
- //
- // Function: WriteString
- //
- // Description: Helper function that writes an ASCII String back
- // to the web client. This function is *not* exported
- // by the DLL, and is only called by HttpExtensionProc
- //
- /*********************************************************************/
-
-
- void WriteString( EXTENSION_CONTROL_BLOCK * pECB,
- LPCTSTR lpString )
- {
- // Calculate length of string to output to client
-
- DWORD dwBytesToWrite = lstrlen(lpString);
-
-
- // Use IIS server call-back function to output text to web-client
-
- pECB->WriteClient( pECB->ConnID,
- (PVOID) lpString,
- &dwBytesToWrite,
- 0 );
- }
-
-
- /*********************************************************************/
- //
- // Function: HttpExtensionProc
- //
- // Description: Function called by the IIS Server when a request
- // for the ISAPI dll arrives. The HttpExtensionProc
- // function processes the request and outputs the
- // appropriate response to the web client using
- // the WriteString helper function provided above.
- //
- /*********************************************************************/
-
-
- DWORD WINAPI HttpExtensionProc( EXTENSION_CONTROL_BLOCK * pecb )
- {
-
- // Set HTML Title
-
- WriteString( pecb,
- TEXT("<HEAD><TITLE> IIS SDK Simple ISAPI Extension </TITLE></HEAD>\r\n\r\n"));
-
-
- // Output Simple Message to Web Page
-
- WriteString( pecb,
- TEXT("<BODY>This is a simple ISAPI Extension from the IIS SDK!</BODY>"));
-
-
- // Define HTML tag close
-
- WriteString( pecb,
- TEXT("\r\n\r\n</TITLE>\r\n"));
-
-
- // Indicate that the call to HttpExtensionProc was successful
-
- return( HSE_STATUS_SUCCESS );
- }
-