punk->release();
}
pqca->release();
}
else
{
hr = e_outofmemory;
}
prot->release();
}
pmoniker->release();
}
return hr;
}
hresult _unregisterforiquerycancelautoplay(dword dwregisterrot)
{
irunningobjecttable *prot;
if (succeeded(getrunningobjecttable(0, &prot)))
{
// remove our instance from the rot
prot->revoke(dwregisterrot);
prot->release();
}
return s_ok;
}
stdmethodimp cquerycancelautoplay::queryinterface(refiid riid, void** ppv)
{
iunknown* punk = null;
hresult hr = s_ok;
if (iid_iunknown == riid)
{
punk = static_cast<iunknown*>(this);
punk->addref();
}
else
{
if (iid_iquerycancelautoplay == riid)
{
punk = static_cast<iquerycancelautoplay*>(this);
punk->addref();
}
else
{
hr = e_nointerface;
}
}
*ppv = punk;
return hr;
}
stdmethodimp_(ulong) cquerycancelautoplay::addref()
{
return ::interlockedincrement((long*)&m_cref);
}
stdmethodimp_(ulong) cquerycancelautoplay::release()
{
ulong cref = ::interlockeddecrement((long*)&m_cref);
if (!cref)
{
delete this;
}
return cref;
}
stdmethodimp cquerycancelautoplay::allowautoplay(lpcwstr pszpath,
dword dwcontenttype, lpcwstr pszlabel, dword dwserialnumber)
{
hresult hr = s_ok;
//do what you want to do
//return s_false to cancel the autoplay
//return s_ok to do autoplay
return hr;
}