SETP1: Add an inheritance class for an ATL interface class
Yourinterface.h
Class ATL_NO_VTABLE CYOURINTERFACE: PUBLIC IOBJECTSAFETYIMPL
Setp2: Add MAP
Begin_COM_MAP (CYOOURINTERFACE) COM_INTERFACE_ENTRY (IOBJECTSAFETY) END_COM_MAP ()
SETP3: The resell definition increases the following two member functions can be registered by safe registration software.
STDMETHOD (GetInterfaceSafetyOptions) (REFIID riid, DWORD * pdwSupportedOptions, DWORD * pdwEnabledOptions) {ATLTRACE (_T ( "CObjectSafetyImpl :: GetInterfaceSafetyOptions / n")); if return E_FAIL (pdwSupportedOptions || pdwEnabledOptions!!); LPUNKNOWN pUnk; if (_InternalQueryInterface (RIID, (void **) {// OUR Object Doesn't Even Support this interface. Return E_NOINTERFACE;} else {// cleanup after ousidelves. punk-> release (); punk = null; } if (riid == IID_IDispatch) {// IDispatch is an interface used for scripting. If your // control supports other IDispatch or Dual interfaces, you // may decide to add them here as well. Client wants to know // if .. object is safe for scripting Only indicate safe for // scripting when the interface is safe * pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER; * pdwEnabledOptions = m_dwCurrentSafety & INTERFACESAFE_FOR_UNTRUSTED_CALLER; return S_OK;} els e if ((riid == IID_IPersistStreamInit) || (riid == IID_IPersistStorage)) {// IID_IPersistStreamInit and IID_IPersistStorage are // interfaces used for Initialization. If your control // supports other Persistence interfaces, you may decide to // add them . here as well Client wants to know if object is // safe for initializing Only indicate safe for initializing // when the interface is safe * pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA;.. * pdwEnabledOptions = m_dwCurrentSafety & INTERFACESAFE_FOR_UNTRUSTED_DATA; return S_OK;
} else {// we are saying what no other interfaces in this control area // Safe for Initializing or scripting. * pdwsupportedOptions = 0; * pdwenabledoptions = 0; return e_fail;}}