本文整理汇总了C++中CContext::Server方法的典型用法代码示例。如果您正苦于以下问题:C++ CContext::Server方法的具体用法?C++ CContext::Server怎么用?C++ CContext::Server使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContext
的用法示例。
在下文中一共展示了CContext::Server方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HasAccess
STDMETHODIMP CPermissionChecker::HasAccess(
BSTR bstrLocalUrl,
VARIANT_BOOL *pfRetVal)
{
HRESULT rc = E_FAIL;
try
{
if (bstrLocalUrl == NULL || pfRetVal == NULL)
return ::ReportError(E_POINTER);
*pfRetVal = VARIANT_FALSE;
CContext cxt;
if ( cxt.Init( CContext::get_Server ) != S_OK )
{
return ::ReportError( E_NOINTERFACE );
}
// Map logical filename to a physical filesystem name
CComBSTR bstrPhysicalFile;
HRESULT hr = cxt.Server()->MapPath(bstrLocalUrl, &bstrPhysicalFile);
if (SUCCEEDED(hr))
*pfRetVal = ::DoesUserHaveAccessToFile(bstrPhysicalFile);
else // failed to map as URL, try as regular path
*pfRetVal = ::DoesUserHaveAccessToFile(bstrLocalUrl);
rc = S_OK;
}
catch( alloc_err& )
{
rc = E_OUTOFMEMORY;
}
catch( ... )
{
rc = E_FAIL;
}
return rc;
}
示例2: get_GetAdvertisement
STDMETHODIMP CAdRotator::get_GetAdvertisement(BSTR bstrVirtualPath, BSTR * pVal)
{
SCODE rc = E_FAIL;
try
{
USES_CONVERSION;
CContext cxt;
rc = cxt.Init( CContext::get_Server );
if ( !FAILED(rc) )
{
CComBSTR bstrPhysicalPath;
// determine the physical path
if ( ( rc = cxt.Server()->MapPath( bstrVirtualPath, &bstrPhysicalPath ) ) == S_OK )
{
_TCHAR* szPath = OLE2T( bstrPhysicalPath );
CAdFilePtr pAdFile = AdFile( szPath );
if ( pAdFile.IsValid() )
{
// refresh the ad file (make sure it's up to date)
pAdFile->Refresh();
// block all writers
CReader rdr( *pAdFile );
// if the border hasn't been set, use the default from the ad file
short nBorder;
if ( m_nBorder < 0 )
{
nBorder = pAdFile->Border();
}
else
{
nBorder = m_nBorder;
}
CAdDescPtr pAd = pAdFile->RandomAd();
if ( pAd.IsValid() )
{
// write out the HTML line for this ad
StringOutStream ss;
if ( m_bClickable && ( pAd->m_strLink.size() > 1 ) )
{
// use the href format
ss << _T("<A HREF=\"") << pAdFile->Redirector()
<< _T("?url=") << pAd->m_strLink
<< _T("&image=") << pAd->m_strGif
<< _T("\" ") << m_strTargetFrame << _T(">");
}
// now fill in the rest
ss << _T("<IMG SRC=\"") << pAd->m_strGif
<< _T("\" ALT=\"") << pAd->m_strAlt
<< _T("\" WIDTH=") << pAdFile->Width()
<< _T(" HEIGHT=") << pAdFile->Height();
if ( pAdFile->HSpace() != CAdFile::defaultHSpace )
{
ss << _T(" HSPACE=") << pAdFile->HSpace();
}
if ( pAdFile->VSpace() != CAdFile::defaultVSpace )
{
ss << _T(" VSPACE=") << pAdFile->VSpace();
}
ss << _T(" BORDER=") << nBorder << _T(">");
if ( m_bClickable && ( pAd->m_strLink.size() > 1 ) )
{
// put the trailing tag on
ss << _T("</A>");
}
String str = ss.toString();
if ( pVal )
{
if ( *pVal )
{
::SysFreeString( *pVal );
}
*pVal = T2BSTR( str.c_str() );
THROW_IF_NULL( *pVal );
rc = S_OK;
}
else
{
rc = E_POINTER;
}
}
}
}
}
else
{
_ASSERT(0);
//.........这里部分代码省略.........