source: trunk/DirectShowSpy/Module.cpp @ 448

Last change on this file since 448 was 376, checked in by roman, 9 years ago

Changed year to 2015; Added Copy and Save As links in graph text, RunTime? property pages

File size: 2.9 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2015
3// Created by Roman Ryltsov roman@alax.info, http://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
8// or otherwise (provided that you don’t 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. It is allowed to distribute
12// DirectShowSpy if only it is not registered with Windows by default and either
13// used privately, or registered on specific throubleshooting request. The advice applies
14// to hooking methods used by DirectShowSpy in general as well.
15
16#include "stdafx.h"
17#include "resource.h"
18#include "Module_i.h"
19#include "dllmain.h"
20
21#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
22        #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."
23#endif
24
25////////////////////////////////////////////////////////////
26// DLL Exports
27
28STDAPI DllCanUnloadNow() throw()
29{
30    return _AtlModule.DllCanUnloadNow();
31}
32STDAPI DllGetClassObject(REFCLSID ClassIdentifier, REFIID InterfaceIdentifier, LPVOID* ppvObject) throw()
33{
34    return _AtlModule.DllGetClassObject(ClassIdentifier, InterfaceIdentifier, ppvObject);
35}
36STDAPI DllRegisterServer() throw()
37{
38        HRESULT nResult;
39        _ATLTRY
40        {
41                nResult = _AtlModule.DllRegisterServer();
42                __C(nResult);
43        }
44        _ATLCATCH(Exception)
45        {
46                _C(Exception);
47        }
48        return nResult;
49}
50STDAPI DllUnregisterServer() throw()
51{
52        HRESULT nResult;
53        _ATLTRY
54        {
55                nResult = _AtlModule.DllUnregisterServer();
56                __C(nResult);
57        }
58        _ATLCATCH(Exception)
59        {
60                _C(Exception);
61        }
62        return nResult;
63}
64STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCommandLine) throw()
65{
66        HRESULT nResult;
67        _ATLTRY
68        {
69                static const WCHAR g_pszUser[] = _T("user");
70                if(pszCommandLine)
71                {
72                if(_wcsnicmp(pszCommandLine, g_pszUser, DIM(g_pszUser)) == 0)
73                        AtlSetPerUserRegistration(TRUE);
74                }
75                if(bInstall)
76                {       
77                nResult = DllRegisterServer();
78                if(FAILED(nResult))
79                        DllUnregisterServer();
80                } else
81                nResult = DllUnregisterServer();
82        }
83        _ATLCATCH(Exception)
84        {
85                _C(Exception);
86        }
87        return nResult;
88}
Note: See TracBrowser for help on using the repository browser.