⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isapiexample.cpp

📁 Visual C++ 的学习资料一
💻 CPP
字号:
// ISAPIEXAMPLE.CPP - Implementation file for your Internet Server
//    IsapiExample Extension

#include "stdafx.h"
#include "IsapiExample.h"

///////////////////////////////////////////////////////////////////////
// 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(CIsapiExampleExtension, CHttpServer)
	// TODO: insert your ON_PARSE_COMMAND() and 
	// ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
	// For example:
	ON_PARSE_COMMAND(ConfirmInfo, CIsapiExampleExtension,ITS_PSTR ITS_PSTR ITS_PSTR ITS_PSTR ITS_PSTR ITS_PSTR )
	ON_PARSE_COMMAND_PARAMS("name sex birth person addr phone")//对应于ConfirmInfo函数的6个字符串参数
	//在HTML表单提交时,需要将name值与ON_PARSE_COMMAND_PARAMS宏中定义的参数一致


	ON_PARSE_COMMAND(Default, CIsapiExampleExtension, ITS_EMPTY)
	DEFAULT_PARSE_COMMAND(Default, CIsapiExampleExtension)


END_PARSE_MAP(CIsapiExampleExtension)


///////////////////////////////////////////////////////////////////////
// The one and only CIsapiExampleExtension object

CIsapiExampleExtension theExtension;


///////////////////////////////////////////////////////////////////////
// CIsapiExampleExtension implementation

CIsapiExampleExtension::CIsapiExampleExtension()
{
}

CIsapiExampleExtension::~CIsapiExampleExtension()
{
}

BOOL CIsapiExampleExtension::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;
}

BOOL CIsapiExampleExtension::TerminateExtension(DWORD dwFlags)
{
	// extension is being terminated
	//TODO: Clean up any per-instance resources
	return TRUE;
}

///////////////////////////////////////////////////////////////////////
// CIsapiExampleExtension command handlers

void CIsapiExampleExtension::Default(CHttpServerContext* pCtxt)
{
	StartContent(pCtxt);
	WriteTitle(pCtxt);

	*pCtxt << _T("This default message was produced by the Internet");
	*pCtxt << _T(" Server DLL Wizard. Edit your CIsapiExampleExtension::Default()");
	*pCtxt << _T(" implementation to change it.\r\n");

	EndContent(pCtxt);
}

// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CIsapiExampleExtension, CHttpServer)
	//{{AFX_MSG_MAP(CIsapiExampleExtension)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0



///////////////////////////////////////////////////////////////////////
// If your extension will not use MFC, you'll need this code to make
// sure the extension objects can find the resource handle for the
// module.  If you convert your extension to not be dependent on MFC,
// remove the comments arounn the following AfxGetResourceHandle()
// and DllMain() functions, as well as the g_hInstance global.

/****

static HINSTANCE g_hInstance;

HINSTANCE AFXISAPI AfxGetResourceHandle()
{
	return g_hInstance;
}

BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
					LPVOID lpReserved)
{
	if (ulReason == DLL_PROCESS_ATTACH)
	{
		g_hInstance = hInst;
	}

	return TRUE;
}

****/

void CIsapiExampleExtension::ConfirmInfo(CHttpServerContext *pCtxt, LPCTSTR name, LPCTSTR sex, LPCTSTR birth, LPCTSTR person, LPCTSTR addr, LPCTSTR phone)
{
	StartContent(pCtxt);
	WriteTitle(pCtxt);

	*pCtxt<<"<h1> 学生信息确认:</h1>";
	*pCtxt<<"<p>姓名: "<<name  <<" </p>";
	*pCtxt<<"<p>性别: "<<sex  <<" </p>";
	*pCtxt<<"<p>出身日期: "<<birth  <<" </p>";
	*pCtxt<<"<p>监护人: "<<person  <<" </p>";
	*pCtxt<<"<p>地址: "<<addr  <<" </p>";
	*pCtxt<<"<p>电话: "<<phone  <<" </p>";

	EndContent(pCtxt);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -