'function': COM 이벤트를 발생하려면 COM 인터페이스여야 합니다.
비고
COM 이벤트를 발생시키는 데 사용하는 이벤트 인터페이스는 COM 인터페이스여야 합니다. 이 경우 인터페이스는 Visual C++ 특성을 사용하여 정의하거나 #import embedded_idl 특성이 있는 형식 라이브러리에서 #import 사용하여 가져와야 합니다.
#include COM 이벤트를 사용하려면 아래 예제에 표시된 ATL 헤더 파일의 줄이 필요합니다. 이 오류를 해결하려면 인터페이스 정의에 다음 특성 중 하나를 적용하여 (이벤트 인터페이스) COM 인터페이스를 만듭니 IEvents 다. 개체, 이중 또는 dispinterface.
인터페이스가 MIDL에서 생성된 헤더 파일의 인터페이스인 경우 컴파일러는 이를 COM 인터페이스로 인식하지 않습니다.
Example
다음 예제에서는 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;
}
};