home *** CD-ROM | disk | FTP | other *** search
- // InvokObj.cpp -> Sample ISAPI extension to invoke an automation server method
- // Wade A. Hilmo, August 1997
-
- #define _WIN32_WINNT 0x0400
-
- #include <windows.h>
- #include <httpext.h>
-
-
- // Import typelibrary information about the COM object
-
- #import "GetUserName.dll"
-
-
- BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)
- {
- pVer->dwExtensionVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
- lstrcpyn(pVer->lpszExtensionDesc, "InvokObj ISAPI Sample", HSE_MAX_EXT_DLL_NAME_LEN);
-
-
- // Ensure COM is initialized
-
- CoInitialize(NULL);
-
- return TRUE;
- }
-
-
- DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *lpEcb)
- {
- char szOutput[1024];
- DWORD dwBuffSize;
- GETUSERNAMELib::IGetUserNameObjPtr pItf;
- HRESULT hr;
-
- // Send headers back to client
-
- lpEcb->ServerSupportFunction(lpEcb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, NULL, NULL, (LPDWORD)"Content-type: text/html\r\n\r\n");
-
-
- // Initialize and instance of the automation server
-
- hr = pItf.CreateInstance(L"GetUserNameObj.GetUserNameObj.1");
-
- if (FAILED(hr))
- {
- wsprintf(szOutput, "<h1>Error.</h1><hr>Attempt to create instance of GetUserNameObj object failed with error %x.", hr);
- dwBuffSize = strlen(szOutput);
-
- lpEcb->WriteClient(lpEcb->ConnID, szOutput, &dwBuffSize, 0);
-
- return HSE_STATUS_SUCCESS;
- }
-
-
- // Build the output using the result of the call to
- // GetUserNameObj's GetMyName method
-
- wsprintf(szOutput, "<h1>GetUserNameObj successfully instantiated.</h1><hr>The GetMyName method returned %s.", (char *)pItf->GetMyName());
-
-
- // Send the output back to the client
-
- dwBuffSize = strlen(szOutput);
- lpEcb->WriteClient(lpEcb->ConnID, szOutput, &dwBuffSize, 0);
-
-
- return HSE_STATUS_SUCCESS;
- }
-
-
- BOOL WINAPI TerminateExtension(DWORD dwFlags)
- {
- // Balance the call to CoInitialize that we made in GetExtensionVersion
-
- CoUninitialize();
-
-
- // It is now OK to unload
-
- return TRUE;
- }
-