📄 cominasp.cpp
字号:
// COMINASP.cpp : Implementation of CCOMINASP
#include "stdafx.h"
#include "ASPCOM.h"
#include "COMINASP.h"
/////////////////////////////////////////////////////////////////////////////
// CCOMINASP
STDMETHODIMP CCOMINASP::get_FirstPar(BSTR *pVal)
{
// TODO: Add your implementation code here
*pVal=One;
return S_OK;
}
STDMETHODIMP CCOMINASP::put_FirstPar(BSTR newVal)
{
// TODO: Add your implementation code here
One=newVal;
return S_OK;
}
STDMETHODIMP CCOMINASP::get_SecondPar(BSTR *pVal)
{
// TODO: Add your implementation code here
*pVal=Sec;
return S_OK;
}
STDMETHODIMP CCOMINASP::put_SecondPar(BSTR newVal)
{
// TODO: Add your implementation code here
Sec=newVal;
return S_OK;
}
STDMETHODIMP CCOMINASP::StrCat(BSTR *ret)
{
// TODO: Add your implementation code here
CComBSTR tmp(One);
tmp.AppendBSTR(Sec);
*ret=tmp.m_str;
return S_OK;
}
STDMETHODIMP CCOMINASP::ProcessPage()
{
HRESULT hr = E_FAIL;
CComPtr<IObjectContext> pObjContext;
hr = ::GetObjectContext(&pObjContext);
CComPtr<IRequest>pRequest=NULL;
CComPtr<IResponse>pResponse=NULL;
CComPtr<ISessionObject>pSession=NULL;
if (SUCCEEDED(hr))
{
CComPtr<IGetContextProperties> pProps;
hr = pObjContext->QueryInterface(IID_IGetContextProperties,(void**)&pProps);
if (SUCCEEDED(hr))
{
CComBSTR bstrASPObj = "Request";
CComVariant vt;
if (SUCCEEDED(pProps->GetProperty(bstrASPObj, &vt)))
{
if (V_VT(&vt)==VT_DISPATCH)
{
IDispatch* pDispatch = V_DISPATCH(&vt);
if (pDispatch)
hr = pDispatch->QueryInterface(IID_IRequest,(void **)&pRequest);
}
}
bstrASPObj="Response";
if (SUCCEEDED(pProps->GetProperty(bstrASPObj, &vt)))
{
if (V_VT(&vt)==VT_DISPATCH)
{
IDispatch* pDispatch = V_DISPATCH(&vt);
if (!pDispatch)
return E_FAIL;
else
hr = pDispatch->QueryInterface(IID_IResponse,(void **)&pResponse);
if (!pResponse)
return E_FAIL;
else
{
CComPtr<IRequestDictionary>pReqDict=NULL;
CComVariant vRequestInfo;
hr=pRequest->get_ServerVariables(&pReqDict);
if(pReqDict)
{
hr=pReqDict->get_Item(CComVariant(L"REMOTE_ADDR"),&vRequestInfo);
hr=pResponse->Write(CComVariant(L"Address: "));
hr=pResponse->Write(vRequestInfo);
hr=pResponse->Write(CComVariant(L"<br>"));
}
}
}
}
bstrASPObj="Session";
if (SUCCEEDED(pProps->GetProperty(bstrASPObj, &vt)))
{
if (V_VT(&vt)==VT_DISPATCH)
{
IDispatch* pDispatch = V_DISPATCH(&vt);
if (!pDispatch)
return E_FAIL;
else
hr = pDispatch->QueryInterface(IID_ISessionObject,(void **)&pSession);
if (!pSession)
return E_FAIL;
else
{
BSTR SID;
pSession->get_SessionID(&SID);
hr=pResponse->Write(CComVariant("SessionID:"));
hr=pResponse->Write(CComVariant(SID));
}
}
}
}
}
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -