source: trunk/Utilities/Miscellaneous/ComIsolation01/Server/TestObject.h @ 531

Last change on this file since 531 was 531, checked in by roman, 8 years ago
File size: 1.8 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2015
3// Created by Roman Ryltsov roman@alax.info
4//
5// A permission to use the source code is granted as long as reference to
6// source website http://alax.info is retained.
7
8#pragma once
9
10#include "resource.h"       // main symbols
11#include "Server_i.h"
12
13#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
14        #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."
15#endif
16
17using namespace ATL;
18
19// CTestObject
20
21class ATL_NO_VTABLE CTestObject :
22        public CComObjectRootEx<CComSingleThreadModel>,
23        public CComCoClass<CTestObject, &CLSID_TestObject>,
24        public IDispatchImpl<ITestObject>
25{
26public:
27
28DECLARE_REGISTRY_RESOURCEID(IDR_TESTOBJECT)
29
30BEGIN_COM_MAP(CTestObject)
31        COM_INTERFACE_ENTRY(ITestObject)
32        COM_INTERFACE_ENTRY(IDispatch)
33END_COM_MAP()
34
35public:
36// CTestObject
37
38// ITestObject
39        STDMETHOD(TestMethod)(BSTR* psPath, LONG* pnBitness)
40        {
41                ATLASSERT(psPath && pnBitness);
42                TCHAR pszPath[MAX_PATH] = { 0 };
43                ATLVERIFY(GetModuleFileName(_AtlBaseModule.GetModuleInstance(), pszPath, _countof(pszPath)));
44                *psPath = CComBSTR(pszPath).Detach();
45                #if defined(_WIN64)
46                        *pnBitness = 64;
47                #else
48                        *pnBitness = 32;
49                #endif
50                return S_OK;
51        }
52};
53
54OBJECT_ENTRY_AUTO(__uuidof(TestObject), CTestObject)
Note: See TracBrowser for help on using the repository browser.