forked from gurnec/HashCheck
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathCHashCheckClassFactory.cpp
More file actions
66 lines (54 loc) · 1.56 KB
/
CHashCheckClassFactory.cpp
File metadata and controls
66 lines (54 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* HashCheck Shell Extension
* Copyright (C) Kai Liu. All rights reserved.
*
* Please refer to readme.txt for information about this source code.
* Please refer to license.txt for details about distribution and modification.
**/
#include "CHashCheckClassFactory.hpp"
#include "CHashCheck.hpp"
#include "CHashCheckExplorerCommand.hpp"
#include <new>
STDMETHODIMP CHashCheckClassFactory::QueryInterface( REFIID riid, LPVOID *ppv )
{
if (IsEqualIID(riid, IID_IUnknown))
{
*ppv = this;
}
else if (IsEqualIID(riid, IID_IClassFactory))
{
*ppv = (LPCLASSFACTORY)this;
}
else
{
*ppv = NULL;
return(E_NOINTERFACE);
}
AddRef();
return(S_OK);
}
STDMETHODIMP CHashCheckClassFactory::CreateInstance( LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppv )
{
*ppv = NULL;
if (pUnkOuter) return(CLASS_E_NOAGGREGATION);
IUnknown *pUnknown = NULL;
switch (m_classObject)
{
case HCCO_EXPLORER_CREATE:
pUnknown = static_cast<IExplorerCommand *>(new(std::nothrow) CHashCheckExplorerCommand(HCEC_CREATE));
break;
case HCCO_EXPLORER_VERIFY:
pUnknown = static_cast<IExplorerCommand *>(new(std::nothrow) CHashCheckExplorerCommand(HCEC_VERIFY));
break;
case HCCO_EXPLORER_OPTIONS:
pUnknown = static_cast<IExplorerCommand *>(new(std::nothrow) CHashCheckExplorerCommand(HCEC_OPTIONS));
break;
default:
pUnknown = static_cast<IShellExtInit *>(new(std::nothrow) CHashCheck);
break;
}
if (pUnknown == NULL) return(E_OUTOFMEMORY);
HRESULT hr = pUnknown->QueryInterface(riid, ppv);
pUnknown->Release();
return(hr);
}