/*===================================================================
Microsoft Denali
Microsoft Confidential.
Copyright 1996 Microsoft Corporation. All Rights Reserved.
Component: Main
File: CoInit.cpp
Owner: DaveK
Sample (and simple!) ISAPI app
===================================================================*/
#include "wtypes.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "stdlib.h"
#include "iisext.h"
#include "objbase.h"
// Globals
char g_szExtensionDesc[] = "CoInit ISAPI test 1.0";
char g_szCoInitSez[] = "\
\
Of all God's creatures there is only one that
\
cannot be made the slave of the lash. That one is the cat.
\
If man could be crossed with a cat it would improve man,
\
but it would deteriorate the cat. \
- Mark CoInit (1835-1910), American author.
\
";
/*===================================================================
BOOL DllInit
Initialize the DLL
Returns:
TRUE on successful initialization
Side effects:
NONE
===================================================================*/
BOOL DllInit( void )
{
OutputDebugString( "CoInit DLL initialized\n" );
return TRUE;
}
/*===================================================================
void DllUnInit
UnInitialize the DLL
Returns:
NONE
Side effects:
NONE
===================================================================*/
void DllUnInit( void )
{
OutputDebugString( "CoInit DLL un-initialized\n" );
}
/*===================================================================
GetExtensionVersion
Mandatory server extension call which returns the version number of
the ISAPI spec that we were built with.
Returns:
TRUE on success
Side effects:
None.
===================================================================*/
BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pextver)
{
// Init the DLL
if ( !DllInit() )
{
return FALSE;
}
if (FAILED( CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) ))
{
return FALSE;
}
OutputDebugString( "CoInit DLL: CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) call succeeded\n" );
pextver->dwExtensionVersion =
MAKELONG(HSE_VERSION_MAJOR, HSE_VERSION_MINOR);
lstrcpy(pextver->lpszExtensionDesc, g_szExtensionDesc);
return TRUE;
}
/*===================================================================
SendHeaderToClient
Returns:
TRUE if success
Side effects:
None.
===================================================================*/
BOOL
SendHeaderToClient( IN EXTENSION_CONTROL_BLOCK * pECB, IN LPCSTR szMessage)
{
char * szStatus = "200 OK";
char szHeader[600];
//
// Note the HTTP header block is terminated by a blank '\r\n' pair,
// followed by the document body
//
wsprintf( szHeader,
"Content-Type: text/html"
"\r\n"
"\r\n" // end of header
"
\