Replace NOERROR with S_OK
[TortoiseGit.git] / src / TortoiseShell / ShellExtClassFactory.cpp
blobc04e0a6284ea536bb426b5cb66735aa5fd7ab741
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006 - Stefan Kueng
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "ShellExt.h"
21 #include "ShellExtClassFactory.h"
23 extern std::set<CShellExt *> g_exts;
25 CShellExtClassFactory::CShellExtClassFactory(FileState state)
27 m_StateToMake = state;
29 m_cRef = 0L;
31 g_cRefThisDll++;
34 CShellExtClassFactory::~CShellExtClassFactory()
36 g_cRefThisDll--;
39 STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid,
40 LPVOID FAR *ppv)
42 *ppv = NULL;
44 // Any interface on this object is the object pointer
46 if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
48 *ppv = (LPCLASSFACTORY)this;
50 AddRef();
52 return S_OK;
55 return E_NOINTERFACE;
58 STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef()
60 return ++m_cRef;
63 STDMETHODIMP_(ULONG) CShellExtClassFactory::Release()
65 if (--m_cRef)
66 return m_cRef;
68 delete this;
70 return 0L;
73 STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
74 REFIID riid,
75 LPVOID *ppvObj)
77 *ppvObj = NULL;
79 // Shell extensions typically don't support aggregation (inheritance)
81 if (pUnkOuter)
82 return CLASS_E_NOAGGREGATION;
84 // Create the main shell extension object. The shell will then call
85 // QueryInterface with IID_IShellExtInit--this is how shell extensions are
86 // initialized.
88 CShellExt* pShellExt = new CShellExt(m_StateToMake); //Create the CShellExt object
90 if (NULL == pShellExt)
91 return E_OUTOFMEMORY;
93 return pShellExt->QueryInterface(riid, ppvObj);
96 STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /*fLock*/)
98 return E_NOTIMPL;