return S_OK; }
else if (riid == IID_IPersistPropertyBag || riid == IID_IPersistStreamInit || riid == IID_IPersistStorage || riid == IID_IPersistMemory) {
// Those are the persistence interfaces COleControl derived controls support // as indicated in AFXCTL.H
// Client wants to know if object is safe for initializing from persistent data *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA; return S_OK; } else {
// Find out what interface this is, and decide what options to enable
TRACE(\\\n\ return E_NOINTERFACE; } }
STDMETHODIMP CTixCtrl::XObjectSafety::SetInterfaceSafetyOptions( REFIID riid,
DWORD dwOptionSetMask, DWORD dwEnabledOptions) {
METHOD_PROLOGUE_EX(CTixCtrl, ObjectSafety) OLECHAR szGUID[39];
// What is this interface anyway?
// We can do a quick lookup in the registry under HKEY_CLASSES_ROOT\\Interface int i = StringFromGUID2(riid, szGUID, 39);
if (0 == dwOptionSetMask && 0 == dwEnabledOptions) {
// the control certainly supports NO requests through the specified interface // so it’s safe to return S_OK even if the interface isn’t supported. return S_OK; }
// Do we support the specified interface? if (NULL == pThis->GetInterface(&riid)) {
TRACE1(\ return E_FAIL; }
if (riid == IID_IDispatch)
{
TRACE(\\\n\ TRACE(\ if (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwOptionSetMask && INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwEnabledOptions) {
return S_OK; } else {
return E_FAIL; } }
else if (riid == IID_IPersistPropertyBag || riid == IID_IPersistStreamInit || riid == IID_IPersistStorage || riid == IID_IPersistMemory) {
TRACE(\\\n\
TRACE(\ if (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwOptionSetMask && INTERFACESAFE_FOR_UNTRUSTED_DATA == dwEnabledOptions) {
return NOERROR; } else {
return E_FAIL; } } else {
TRACE1(\\\n\ return E_FAIL; } }
STDMETHODIMP_(ULONG) CTixCtrl::XObjectSafety::AddRef() {
METHOD_PROLOGUE_EX_(CTixCtrl, ObjectSafety) return (ULONG)pThis->ExternalAddRef(); }
STDMETHODIMP_(ULONG) CTixCtrl::XObjectSafety::Release() {
METHOD_PROLOGUE_EX_(CTixCtrl, ObjectSafety)
return (ULONG)pThis->ExternalRelease(); }
STDMETHODIMP CTixCtrl::XObjectSafety::QueryInterface( REFIID iid, LPVOID* ppvObj) {
METHOD_PROLOGUE_EX_(CTixCtrl, ObjectSafety)
return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj); }
4.加入接口映射表中 在tixctl.h中加入声明
DECLARE_INTERFACE_MAP() 在 tixctl.cpp中加入
BEGIN_INTERFACE_MAP(CTixCtrl, COleControl)
INTERFACE_PART(CTixCtrl, IID_IObjectSafety, ObjectSafety) END_INTERFACE_MAP()
好了,试试,没问题了吧。
相关推荐: