नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'function' : must be a COM interface to fire COM events
Remarks
The event interface that you use to fire COM events must be a COM interface. In this situation, the interface should either be defined using a Visual C++ attribute, or imported using #import from a type library with #import's embedded_idl attribute.
Note that the #include lines of the ATL header files shown in the example below are required for using COM events. To fix this error, make IEvents (the eventing interface) a COM interface by applying one of the following attributes to the interface definition: object, dual, or dispinterface.
If an interface is from a header file generated by MIDL, the compiler will not recognize it as a COM interface.
Example
The following example generates C3706:
// C3706.cpp
// compile with: /c
// C3706 expected
#define _ATL_ATTRIBUTES 1
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
[module(dll, name="idid", uuid="12341234-1234-1234-1234-123412341234")];
// Uncomment the following line to resolve.
// [object, uuid="12341234-1234-1234-1234-123412341237"]
__interface IEvents : IUnknown {
HRESULT event1(/*[in]*/ int i); // uncomment [in]
};
[dual, uuid="12341234-1234-1234-1234-123412341235"]
__interface IBase {
HRESULT fireEvents();
};
[coclass, event_source(com), uuid="12341234-1234-1234-1234-123412341236"]
class CEventSrc : public IBase {
public:
__event __interface IEvents;
HRESULT fireEvents() {
HRESULT hr = IEvents_event1(123);
return hr;
}
};