1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2008-2014 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | // |
---|
5 | // This source code is published to complement DirectShowSpy developer powertoy |
---|
6 | // and demonstrate the internal use of APIs and tricks powering the tool. It is |
---|
7 | // allowed to freely re-use the portions of the code in other projects, commercial or otherwise |
---|
8 | // (provided that you dont pretend that you wrote the original tool). |
---|
9 | // |
---|
10 | // Please keep in mind that DirectShowSpy is a developer tool, it is strongly recommended |
---|
11 | // that it is not shipped with release grade software. The advise applies to hooking methods |
---|
12 | // used by DirectShowSpy in general as well. |
---|
13 | |
---|
14 | #include "stdafx.h" |
---|
15 | #include "resource.h" |
---|
16 | #include "DirectShowSpy_i.h" |
---|
17 | #include "dllmain.h" |
---|
18 | |
---|
19 | #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) |
---|
20 | #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." |
---|
21 | #endif |
---|
22 | |
---|
23 | //////////////////////////////////////////////////////////// |
---|
24 | // DLL Exports |
---|
25 | |
---|
26 | STDAPI DllCanUnloadNow() throw() |
---|
27 | { |
---|
28 | return _AtlModule.DllCanUnloadNow(); |
---|
29 | } |
---|
30 | STDAPI DllGetClassObject(REFCLSID ClassIdentifier, REFIID InterfaceIdentifier, LPVOID* ppvObject) throw() |
---|
31 | { |
---|
32 | return _AtlModule.DllGetClassObject(ClassIdentifier, InterfaceIdentifier, ppvObject); |
---|
33 | } |
---|
34 | STDAPI DllRegisterServer() throw() |
---|
35 | { |
---|
36 | HRESULT nResult; |
---|
37 | _ATLTRY |
---|
38 | { |
---|
39 | nResult = _AtlModule.DllRegisterServer(); |
---|
40 | __C(nResult); |
---|
41 | } |
---|
42 | _ATLCATCH(Exception) |
---|
43 | { |
---|
44 | _C(Exception); |
---|
45 | } |
---|
46 | return nResult; |
---|
47 | } |
---|
48 | STDAPI DllUnregisterServer() throw() |
---|
49 | { |
---|
50 | HRESULT nResult; |
---|
51 | _ATLTRY |
---|
52 | { |
---|
53 | nResult = _AtlModule.DllUnregisterServer(); |
---|
54 | __C(nResult); |
---|
55 | } |
---|
56 | _ATLCATCH(Exception) |
---|
57 | { |
---|
58 | _C(Exception); |
---|
59 | } |
---|
60 | return nResult; |
---|
61 | } |
---|
62 | STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCommandLine) throw() |
---|
63 | { |
---|
64 | HRESULT nResult; |
---|
65 | _ATLTRY |
---|
66 | { |
---|
67 | static const WCHAR g_pszUser[] = _T("user"); |
---|
68 | if(pszCommandLine) |
---|
69 | { |
---|
70 | if(_wcsnicmp(pszCommandLine, g_pszUser, DIM(g_pszUser)) == 0) |
---|
71 | AtlSetPerUserRegistration(TRUE); |
---|
72 | } |
---|
73 | if(bInstall) |
---|
74 | { |
---|
75 | nResult = DllRegisterServer(); |
---|
76 | if(FAILED(nResult)) |
---|
77 | DllUnregisterServer(); |
---|
78 | } else |
---|
79 | nResult = DllUnregisterServer(); |
---|
80 | } |
---|
81 | _ATLCATCH(Exception) |
---|
82 | { |
---|
83 | _C(Exception); |
---|
84 | } |
---|
85 | return nResult; |
---|
86 | } |
---|