WINCE ISAPI CGI ASP 小结

系统 2088 0

经过多天的努力 终于搞定了ISAPI 并不是完全搞定 符合自己的需求了

目前先写这些 看不懂的话 留言 我只会WINCE6.0 PB用的是6 其他的不懂了

需求WINCE 里面搭建个类似IIS 发布网站 做类似路由的网页 更改IP或者其他的

方式1、 用CGI 必须移植goahead

方式2、 用ISAPI 系统添加组件后支持

方式3、 COM组件

我用的是ISAPI方式实现的

WINCE 自带web服务器 但是不支持ASP 所以添加组件让他来支持ASP

参考 http://zxffl.blog.163.com/blog/static/25909762010102475353451/ wince6.0 web开发

图1

WINCE ISAPI CGI ASP 小结

002

WINCE ISAPI CGI ASP 小结

主要修改的的是以上2个图的内容

这个是tracker.dll

咱们自己修改tracker.dll中的内容

例如

看这里 判断URL中有没有修改IP 有的话自己修改了 这里用的是修改注册表的方法

    if (strstr(lpEcb->lpszQueryString,"修改IP"))
	{
		//此处写修改IP的代码
// Dump the log
		strcpy(outbuf, "content-type: text/html\r\n\r\n");
		outbuflen = strlen(outbuf);
		lpEcb->ServerSupportFunction(lpEcb->ConnID,
			                         HSE_REQ_SEND_RESPONSE_HEADER,
									 NULL,
									 &outbuflen,
									 (LPDWORD)outbuf);

		
		LPCTSTR lp_Path=TEXT("Comm\\DM9CE1\\Parms\\TcpIp");
		LPCTSTR lp_Key=TEXT("IpAddress");
		LPCTSTR lp_Val=TEXT("192.168.1.235");
		bool bOk=false;
		HKEY hKEY;
		DWORD type_1=REG_SZ; 
		long ret0=(::RegOpenKeyEx(HKEY_LOCAL_MACHINE, lp_Path, 0, KEY_WRITE,&hKEY)); 
		if(ret0==ERROR_SUCCESS) 
		{ 
			long ret1=::RegSetValueEx(hKEY, lp_Key, NULL, type_1, (LPBYTE)lp_Val, 100); 
			if(ret1==ERROR_SUCCESS) 
			{			
				::RegCloseKey(hKEY);
				bOk=true;
			} 			
		} 
		if (bOk)
		{

			strcpy(outbuf,"<HTML><TITLE>IIS Tracker Log    zhangsan</TITLE></HTML> \n\
							   <H1>192.168.1.235 修改成功</H1> \n\
							   <hr>\n");
		}
		else
		{

			strcpy(outbuf,"<HTML><TITLE>IIS Tracker Log    zhangsan</TITLE></HTML> \n\
							   <H1>修改IP失败</H1> \n\
							   <hr>\n");
		}

		strlen(lp_Path);




		//strcpy(outbuf,"<HTML><TITLE>IIS Tracker Log    zhangsan</TITLE></HTML> \n\
		//				   <H1>IIS Tracker Log   2012-0315</H1> \n\
		//				   <hr>\n");


		outbuflen = strlen(outbuf);
		lpEcb->WriteClient(lpEcb->ConnID,
		                   outbuf,
						   &outbuflen,
						   HSE_IO_SYNC);

		EnterCriticalSection(&LogCS);
		if (pLogStart > pLogStop)
		{
			DWORD firstbuflen = ((DWORD)pLogBuff + dwLogBuffSize) - (DWORD)pLogStart;
			DWORD secondbuflen = (DWORD)pLogStop - (DWORD)pLogBuff;
			DWORD outbuflen = firstbuflen + secondbuflen;

			char *pOutput = (char*)HeapAlloc(GetProcessHeap(), 0, outbuflen);
			memcpy(pOutput, pLogStart, firstbuflen);
			memcpy(pOutput + firstbuflen, pLogBuff, secondbuflen);
			LeaveCriticalSection(&LogCS);
			lpEcb->WriteClient(lpEcb->ConnID,
				               pOutput,
							   &outbuflen,
							   HSE_IO_SYNC);
			HeapFree(GetProcessHeap(), 0, pOutput);
		}
		else
		{
			outbuflen = (DWORD)pLogStop - (DWORD)pLogStart;
			char *pOutput = (char*)HeapAlloc(GetProcessHeap(), 0, outbuflen);
			memcpy(pOutput, pLogStart, outbuflen);
			LeaveCriticalSection(&LogCS);
			lpEcb->WriteClient(lpEcb->ConnID,
				               pOutput,
							   &outbuflen,
							   HSE_IO_SYNC);
			HeapFree(GetProcessHeap(), 0, pOutput);
		}		
		strcpy(outbuf, "\n</html>");
		outbuflen = strlen(outbuf);
		lpEcb->WriteClient(lpEcb->ConnID,
			               outbuf,
						   &outbuflen,
						   HSE_IO_SYNC);
		return HSE_STATUS_SUCCESS;



	}


	if (strstr(lpEcb->lpszQueryString, "View"))
	{
		// Dump the log
		strcpy(outbuf, "content-type: text/html\r\n\r\n");
		outbuflen = strlen(outbuf);
		lpEcb->ServerSupportFunction(lpEcb->ConnID,
			                         HSE_REQ_SEND_RESPONSE_HEADER,
									 NULL,
									 &outbuflen,
									 (LPDWORD)outbuf);

		strcpy(outbuf,"<HTML><TITLE>IIS Tracker Log</TITLE></HTML> \n\
						   <H1>IIS Tracker Log</H1> \n\
						   <hr>\n");
		outbuflen = strlen(outbuf);
		lpEcb->WriteClient(lpEcb->ConnID,
		                   outbuf,
						   &outbuflen,
						   HSE_IO_SYNC);

		EnterCriticalSection(&LogCS);
		if (pLogStart > pLogStop)
		{
			DWORD firstbuflen = ((DWORD)pLogBuff + dwLogBuffSize) - (DWORD)pLogStart;
			DWORD secondbuflen = (DWORD)pLogStop - (DWORD)pLogBuff;
			DWORD outbuflen = firstbuflen + secondbuflen;

			char *pOutput = (char*)HeapAlloc(GetProcessHeap(), 0, outbuflen);
			memcpy(pOutput, pLogStart, firstbuflen);
			memcpy(pOutput + firstbuflen, pLogBuff, secondbuflen);
			LeaveCriticalSection(&LogCS);
			lpEcb->WriteClient(lpEcb->ConnID,
				               pOutput,
							   &outbuflen,
							   HSE_IO_SYNC);
			HeapFree(GetProcessHeap(), 0, pOutput);
		}
		else
		{
			outbuflen = (DWORD)pLogStop - (DWORD)pLogStart;
			char *pOutput = (char*)HeapAlloc(GetProcessHeap(), 0, outbuflen);
			memcpy(pOutput, pLogStart, outbuflen);
			LeaveCriticalSection(&LogCS);
			lpEcb->WriteClient(lpEcb->ConnID,
				               pOutput,
							   &outbuflen,
							   HSE_IO_SYNC);
			HeapFree(GetProcessHeap(), 0, pOutput);
		}
		strcpy(outbuf, "\n</html>");
		outbuflen = strlen(outbuf);
		lpEcb->WriteClient(lpEcb->ConnID,
			               outbuf,
						   &outbuflen,
						   HSE_IO_SYNC);
		return HSE_STATUS_SUCCESS;
		
	}
	if (strstr(lpEcb->lpszQueryString, "Clear"))
	{
		EnterCriticalSection(&LogCS);
		pLogStart = pLogStop = pLogBuff;
		LeaveCriticalSection(&LogCS);
		Stamp(0);
		strcpy(outbuf, "<FONT SIZE=+2> Log cleared.</FONT>\n");
		LogWrite(outbuf, strlen(outbuf));
		LogConfig();
		strcpy(outbuf, "content-type: text/html\r\n\r\n");
		outbuflen = strlen(outbuf);
		lpEcb->ServerSupportFunction(lpEcb->ConnID,
			                         HSE_REQ_SEND_RESPONSE_HEADER,
									 NULL,
									 &outbuflen,
									 (LPDWORD)outbuf);

		strcpy(outbuf,"<HTML> \n\
                        <HEAD> \n\
                        <TITLE>IIS Tracker Utility</TITLE> \n\
                        </HEAD> \n\
                        <BODY> \n\
                        <H1>IIS Tracker Utility</H1> \n\
						<H2>Log Successfully Cleared</H2>\n");
		outbuflen = strlen(outbuf);
		lpEcb->WriteClient(lpEcb->ConnID,
		                   outbuf,
						   &outbuflen,
						   HSE_IO_SYNC);
		ShowConfig(lpEcb);
		strcpy(outbuf, "</BODY></HTML>");
		outbuflen = strlen(outbuf);
		lpEcb->WriteClient(lpEcb->ConnID,
		                   outbuf,
						   &outbuflen,
						   HSE_IO_SYNC);
		return HSE_STATUS_SUCCESS;
	}

  


WINCE ISAPI CGI ASP 小结


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论