source: trunk/Utilities/VbsEvents/Foo.h @ 79

Last change on this file since 79 was 79, checked in by roman, 10 years ago
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2012
3// Created by Roman Ryltsov roman@alax.info
4//
5// $Id: Foo.h 79 2012-07-30 16:20:06Z roman $
6
7#pragma once
8
9#include <atlstr.h>
10#include "resource.h"       // main symbols
11#include "VbsEvents_i.h"
12#include "_IFooEvents_CP.h"
13
14#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
15#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
16#endif
17
18using namespace ATL;
19
20////////////////////////////////////////////////////////////
21// CFoo
22
23class ATL_NO_VTABLE CFoo :
24        public CComObjectRootEx<CComSingleThreadModel>,
25        public CComCoClass<CFoo, &CLSID_Foo>,
26        public IConnectionPointContainerImpl<CFoo>,
27        public CProxy_IFooEvents<CFoo>,
28        public IDispatchImpl<IFoo, &IID_IFoo, &LIBID_VbsEventsLib, 1, 0>,
29        public IProvideClassInfo2Impl<&__uuidof(Foo), &__uuidof(_IFooEvents)>
30{
31public:
32
33DECLARE_REGISTRY_RESOURCEID(IDR_FOO)
34
35DECLARE_PROTECT_FINAL_CONSTRUCT()
36
37BEGIN_COM_MAP(CFoo)
38        COM_INTERFACE_ENTRY(IFoo)
39        COM_INTERFACE_ENTRY(IDispatch)
40        COM_INTERFACE_ENTRY(IConnectionPointContainer)
41END_COM_MAP()
42
43BEGIN_CONNECTION_POINT_MAP(CFoo)
44        CONNECTION_POINT_ENTRY(__uuidof(_IFooEvents))
45END_CONNECTION_POINT_MAP()
46
47public:
48// CFoo
49        CFoo()
50        {
51                ATLTRACE(atlTraceRefcount, 4, _T("this 0x%p\n"), this);
52        }
53
54// IFoo
55        STDMETHOD(Method)(BSTR sText) throw()
56        {
57                ATLTRACE(atlTraceCOM, 4, _T("sText \"%s\"\n"), CString(sText));
58                ATLVERIFY(SUCCEEDED(Fire_Event(sText)));
59                return S_OK;
60        }
61};
62
63OBJECT_ENTRY_AUTO(__uuidof(Foo), CFoo)
Note: See TracBrowser for help on using the repository browser.