// LTISAPI.CPP - Implementation file for your Internet Server // LEADTOOLS ISAPI Extension // // To use this example, you must create a directory of 31 images (any format // supported by LEADTOOLS). The images must be named 1, 2, 3, etc. with no // extension up to 31. // // This ISAPI DLL can be called in two ways: // // 1) use the dll to return an IMG: // // will return a jpeg image corresponding to the day of the month // // 2) use the dll in an input form: //
//

Enter // the text you want placed on the image:

//
// will return a jpeg image corresponding to the day of the month with // the string "xxx" written on it. // // Compile this DLL, and place it in your IIS Server's scripts directory. // // See the bottom of this source file for a sample HTML page that // calls this ISAPI DLL. // Or, use the sample page "ISAPI.HTM" #include "stdafx.h" #include "LTISAPI.h" // This program sends back jpeg images rather than HTML. static const TCHAR szContentType[] = _T("Content-Type: image/pjpeg\r\n"); // This should be the location of the source image files // change this for your server static const TCHAR szImagePath[] = _T("D:\\images\\daily\\"); static const TCHAR szImageType[] = _T(".cmp"); // The following two headers will tell the client never to cache // this information, as it is dynamic. static const TCHAR szExpires[] = _T("Expires: Thu, 01 Jan 1995 01:00:00 GMT\r\n"); static const TCHAR szNoCache[] = _T("Pragma: no-cache\r\n"); static const TCHAR szError[] = _T("Error getting image!\r\n"); /////////////////////////////////////////////////////////////////////// // The one and only CWinApp object // NOTE: You may remove this object if you alter your project to no // longer use MFC in a DLL. CWinApp theApp; /////////////////////////////////////////////////////////////////////// // command-parsing map BEGIN_PARSE_MAP(CLTISAPIExtension, CHttpServer) // TODO: insert your ON_PARSE_COMMAND() and // ON_PARSE_COMMAND_PARAMS() here to hook up your commands. // For example: ON_PARSE_COMMAND(Default, CLTISAPIExtension, ITS_EMPTY) ON_PARSE_COMMAND(MyText, CLTISAPIExtension, ITS_PSTR) DEFAULT_PARSE_COMMAND(Default, CLTISAPIExtension) END_PARSE_MAP(CLTISAPIExtension) /////////////////////////////////////////////////////////////////////// // The one and only CLTISAPIExtension object CLTISAPIExtension theExtension; /////////////////////////////////////////////////////////////////////// // CLTISAPIExtension implementation CLTISAPIExtension::CLTISAPIExtension() { } CLTISAPIExtension::~CLTISAPIExtension() { } BOOL CLTISAPIExtension::GetExtensionVersion(HSE_VERSION_INFO* pVer) { // Call default implementation for initialization CHttpServer::GetExtensionVersion(pVer); // Load description string TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1]; ISAPIVERIFY(::LoadString(AfxGetResourceHandle(), IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN)); _tcscpy(pVer->lpszExtensionDesc, sz); return TRUE; } /////////////////////////////////////////////////////////////////////// // CLTISAPIExtension command handlers void CLTISAPIExtension::Default(CHttpServerContext* pCtxt) { CString szFile; CString szMyText; // StartContent(pCtxt); // WriteTitle(pCtxt); // // *pCtxt << _T("This default message was produced by the Internet"); // *pCtxt << _T(" Server DLL Wizard. Edit your CLTISAPIExtension::Default()"); // *pCtxt << _T(" implementation to change it.\r\n"); // We don't call StartContent() or WriteTitle() here due to the // fact that those will send back tags appropriate only to // HTML pages. We will be sending back an image. // Don't allow these pages to be cached AddHeader(pCtxt, szExpires); AddHeader(pCtxt, szNoCache); szFile = GetTodaysImage(); //Send back the image as image/pjpeg OutputJPEG(pCtxt, szFile, szMyText); // EndContent() is only appropriate for HTML files, so we // don't call it here. } void CLTISAPIExtension::MyText(CHttpServerContext* pCtxt, LPTSTR pszMyText) { CString szFile; CString szMyText=""; CString szTemp; CString szToken="MyText="; int nIndex=0; // Don't allow these pages to be cached AddHeader(pCtxt, szExpires); AddHeader(pCtxt, szNoCache); szFile = GetTodaysImage(); //Get the user's text input szTemp = pCtxt->m_pECB->lpbData; nIndex = szTemp.Find(szToken); szMyText = szTemp.Right(szTemp.GetLength() - (nIndex + szToken.GetLength())); //Convert "+" to " " int x; for(x=0;x ISAPI Example Test Page

LEADTOOLS ISAPI Test Page!

Daily image:


To see the daily image with Text on it:

Enter the text you want placed on the image:

© 1991-2000 LEAD Technologies, Inc.

***********************************************************************/ ////////////////////////// Sample HTML page/////////////////////////////