c_str()))
{
m_cursor++;
cActual++;
}
else // allocation error, unwind
{
while (cActual > 0)
{
cActual–;
CoTaskMemFree(rgElems[cActual]);
rgElems[cActual] = 0;
}
break;
}
}
Unlock();
if (cActual)
*pcFetched = cActual;
return cActual == cElems ? S_OK : S_FALSE;
}
STDMETHODIMP
SessionNamesEnumerator::Skip(ULONG cElems)
{
ULONG cActual = 0;
vector
&rstrings = Strings();
Lock();
while (cActual < cElems
&& m_cursor != rstrings.end())
{
m_cursor++;
cActual++;
}
Unlock();
return cActual == cElems ? S_OK : S_FALSE;
}
STDMETHODIMP
SessionNamesEnumerator::Reset(void)
{
Lock();
m_cursor = Strings().begin();
Unlock();
return S_OK;
}
STDMETHODIMP
SessionNamesEnumerator::Clone(IEnumString **ppes)
{
if (ppes == 0)
return E_INVALIDARG;
SessionNamesEnumerator *pCloneSource = m_pCloneSource;
if (pCloneSource == 0) // we are the source
m_pCloneSource = this;
*ppes = new SessionNamesEnumerator(pCloneSource);
if (*ppes)
{
(*ppes)->AddRef();
return S_OK;
}
return E_OUTOFMEMORY;
}
svc.cpp
/////////////////////////////////////////////////////
//
// svc.cpp
//
// Copyright 1997, Don Box/Addison Wesley
//
// This code accompanies the book "The Component
// Object Model" from Addison Wesley. Blah blah blah
//
//
#define _WIN32_WINNT 0x403
#include
#include
#include
#include
#include «ChatSession.h»
#include «../include/COMChat_i.c»
#if !defined(HAVE_IID_IACCESSCONTROL)
// there is a common bug is the SDK headers and libs
// that causes IID_IAccessControl to be undefined.
// We define it here to give the GUID linkage.
DEFINE_GUID(IID_IAccessControl,0xEEDD23E0, 0x8410, 0x11CE,
0xA1, 0xC3, 0x08, 0x00, 0x2B, 0x2B, 0x8D, 0x8F);
#endif
// standard MTA lifetime management helpers
HANDLE g_heventDone = CreateEvent(0, TRUE, FALSE, 0);
void ModuleLock(void)
{
CoAddRefServerProcess();
}
void ModuleUnlock(void)
{
if (CoReleaseServerProcess() == 0)
SetEvent(g_heventDone);
}
// standard self-registration table
const char *g_RegTable[][3] = {
{ «CLSID\\{5223A053-2441-11d1-AF4F-0060976AA886}»,
0, «ChatSession» },
{ «CLSID\\{5223A053-2441-11d1-AF4F-0060976AA886}»,
«AppId», «{5223A054-2441-11d1-AF4F-0060976AA886}»
|< Пред. 521 522 523 524 525 След. >|