home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap14 / lst14_01 / lst14_01.cpp next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  3.2 KB  |  127 lines

  1. // LST14_01.CPP - Implementation file for your Internet Server
  2. //    lst14_01 Extension
  3.  
  4. #include <afx.h>
  5. #include <afxwin.h>
  6. #include <afxisapi.h>
  7. #include "resource.h"
  8. #include "lst14_01.h"
  9.  
  10. ///////////////////////////////////////////////////////////////////////
  11. // command-parsing map
  12.  
  13. BEGIN_PARSE_MAP(CLst14_01Extension, CHttpServer)
  14.     // TODO: insert your ON_PARSE_COMMAND() and 
  15.     // ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
  16.     // For example:
  17.  
  18.     ON_PARSE_COMMAND(Default, CLst14_01Extension, ITS_EMPTY)
  19.     ON_PARSE_COMMAND(Hello, CLst14_01Extension, ITS_EMPTY)
  20.     ON_PARSE_COMMAND(GetName, CLst14_01Extension, ITS_PSTR)
  21.     ON_PARSE_COMMAND_PARAMS("Name")
  22.     DEFAULT_PARSE_COMMAND(Default, CLst14_01Extension)
  23. END_PARSE_MAP(CLst14_01Extension)
  24.  
  25.  
  26. ///////////////////////////////////////////////////////////////////////
  27. // The one and only CLst14_01Extension object
  28.  
  29. CLst14_01Extension theExtension;
  30. CWinApp BugFix;
  31.  
  32. ///////////////////////////////////////////////////////////////////////
  33. // CLst14_01Extension implementation
  34.  
  35. CLst14_01Extension::CLst14_01Extension()
  36. {
  37.     TRACE("Constructor\n");
  38.     m_pnCounter = new UINT;
  39.     (*m_pnCounter) = 0;
  40. }
  41.  
  42. CLst14_01Extension::~CLst14_01Extension()
  43. {
  44.     TRACE("Destructor\n");
  45.     delete     m_pnCounter;
  46. }
  47.  
  48. BOOL CLst14_01Extension::GetExtensionVersion(HSE_VERSION_INFO* pVer)
  49. {
  50.     // Call default implementation for initialization
  51.     CHttpServer::GetExtensionVersion(pVer);
  52.  
  53.     // Load description string
  54.     TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1];
  55.     ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
  56.             IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN));
  57.     _tcscpy(pVer->lpszExtensionDesc, sz);
  58.     return TRUE;
  59. }
  60.  
  61. ///////////////////////////////////////////////////////////////////////
  62. // CLst14_01Extension command handlers
  63.  
  64. void CLst14_01Extension::Default(CHttpServerContext* pCtxt)
  65. {
  66.     StartContent(pCtxt);
  67.     WriteTitle(pCtxt);
  68.  
  69.     *pCtxt << _T("This default message was produced by the Internet");
  70.     *pCtxt << _T(" Server DLL Wizard. Edit your CLst14_01Extension::Default()");
  71.     *pCtxt << _T(" implementation to change it.\r\n");
  72.  
  73.     EndContent(pCtxt);
  74. }
  75.  
  76.  
  77. void CLst14_01Extension::Hello(CHttpServerContext* pCtxt)
  78. {
  79.     StartContent(pCtxt);
  80.     WriteTitle(pCtxt);
  81.  
  82.     *pCtxt << _T("Hello World\r\n");
  83.  
  84.     EndContent(pCtxt);
  85. }
  86.  
  87. void CLst14_01Extension::GetName(CHttpServerContext* pCtxt, LPCTSTR pName)
  88. {
  89.     StartContent(pCtxt);
  90.     WriteTitle(pCtxt);
  91.  
  92.     *pCtxt << _T("Name: ");
  93.      *pCtxt << pName;
  94.     *pCtxt << _T("<BR>\r\n");
  95.  
  96.     EndContent(pCtxt);
  97. }
  98.  
  99. ///////////////////////////////////////////////////////////////////////
  100. // If your extension will not use MFC, you'll need this code to make
  101. // sure the extension objects can find the resource handle for the
  102. // module.  If you convert your extension to not be dependent on MFC,
  103. // remove the comments arounn the following AfxGetResourceHandle()
  104. // and DllMain() functions, as well as the g_hInstance global.
  105.  
  106. /****
  107.  
  108. static HINSTANCE g_hInstance;
  109.  
  110. HINSTANCE AFXISAPI AfxGetResourceHandle()
  111. {
  112.     return g_hInstance;
  113. }
  114.  
  115. BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
  116.                     LPVOID lpReserved)
  117. {
  118.     if (ulReason == DLL_PROCESS_ATTACH)
  119.     {
  120.         g_hInstance = hInst;
  121.     }
  122.  
  123.     return TRUE;
  124. }
  125.  
  126. ****/
  127.