activex 添加 iobjectsafety

activex 添加 iobjectsafety


1. 添加  #include "atlctl.h"


2. 在继承类中添加public IObjectSafetyImpl<Cprinter,INTERFACESAFE_FOR_UNTRUSTED_

CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA>,


3.// 实现安全接口  COM_INTERFACE_ENTRY(IObjectSafety)



例子 


// zpsdk.h : Declaration of the Czpsdk


#ifndef __ZPSDK_H_
#define __ZPSDK_H_


#include "resource.h"       // main symbols
#include <atlctl.h>
/////////////////////////////////////////////////////////////////////////////
// Czpsdk
class ATL_NO_VTABLE Czpsdk : 
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<Czpsdk, &CLSID_zpsdk>,
public IObjectSafetyImpl<Czpsdk,INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA>,
public IDispatchImpl<Izpsdk, &IID_Izpsdk, &LIBID_TESTLib>
{
public:
Czpsdk()
{
}


DECLARE_REGISTRY_RESOURCEID(IDR_ZPSDK)


DECLARE_PROTECT_FINAL_CONSTRUCT()


BEGIN_COM_MAP(Czpsdk)
COM_INTERFACE_ENTRY(Izpsdk)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IObjectSafety)
END_COM_MAP()


// Izpsdk
public:
};


#endif //__ZPSDK_H_

你可能感兴趣的:(interface)