3 ==============================================================================
5 This file is part of the Shooting3
6 Copyright 2005-11 by Satoshi Fujiwara.
8 mini timer can be redistributed and/or modified under the terms of the
9 GNU General Public License, as published by the Free Software Foundation;
10 either version 2 of the License, or (at your option) any later version.
12 mini timer is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with mini timer; if not, visit www.gnu.org/licenses or write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
22 ==============================================================================
26 * @author S.F. (Satoshi Fujiwara)
34 apartment_threaded = 0x2,
35 disable_ole1dde = 0x4,
36 speed_over_memory = 0x8
42 com_initialize(void * reserved = NULL,unsigned int init = multi_threaded);
45 boost::shared_ptr<impl> m_impl;
48 template <typename ComClass,typename ComInterface>
49 boost::intrusive_ptr<ComInterface> create_instance()
51 ComInterface * com_ptr;
52 CoCreateInstance( __uuidof(ComClass), NULL,
53 CLSCTX_ALL, __uuidof(ComInterface),
55 return boost::intrusive_ptr<ComInterface>(com_ptr,false);
58 template <typename COMInterface>
59 struct IUnknownImpl : public COMInterface
61 IUnknownImpl() : ref_(1) {};
62 virtual ~IUnknownImpl() {};
63 ULONG __stdcall AddRef()
65 return InterlockedIncrement(&ref_);
68 ULONG __stdcall Release()
70 ULONG ref = InterlockedDecrement(&ref_);
78 HRESULT __stdcall QueryInterface(REFIID riid, VOID **ppObj)
80 if (IID_IUnknown == riid)
83 *ppObj = (IUnknown*)this;
85 else if (__uuidof(COMInterface) == riid)
88 *ppObj = (COMInterface*)this;