source: trunk/eraser6/ShellExt/DllMain.cpp @ 1360

Revision 1360, 2.7 KB checked in by lowjoel, 4 years ago (diff)

Eraser's still under development, so update the copyright notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev
Line 
1/*
2 * $Id$
3 * Copyright 2008-2009 The Eraser Project
4 * Original Author: Kasra Nassiri <cjax@users.sourceforge.net>
5 * Modified By: Joel Low <lowjoel@users.sourceforge.net>
6 *
7 * This file is part of Eraser.
8 *
9 * Eraser is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 *
18 * A copy of the GNU General Public License can be found at
19 * <http://www.gnu.org/licenses/>.
20 */
21
22#include "stdafx.h"
23#include "resource.h"
24#include "ShellExt_i.h"
25#include "DllMain.h"
26
27CEraserShellExtModule _AtlModule;
28CEraserShellExtApp theApp;
29BEGIN_MESSAGE_MAP(CEraserShellExtApp, CWinApp)
30END_MESSAGE_MAP()
31
32namespace {
33    void InvalidParameterHandler(const wchar_t* /*expression*/, const wchar_t* /*function*/,
34        const wchar_t* /*file*/, unsigned int /*line*/, uintptr_t /*pReserved*/)
35    {
36    }
37}
38
39BOOL CEraserShellExtApp::InitInstance()
40{
41    _set_invalid_parameter_handler(InvalidParameterHandler);
42    return CWinApp::InitInstance();
43}
44
45int CEraserShellExtApp::ExitInstance()
46{
47    return CWinApp::ExitInstance();
48}
49
50//Used to determine whether the DLL can be unloaded by OLE
51STDAPI DllCanUnloadNow(void)
52{
53    AFX_MANAGE_STATE(AfxGetStaticModuleState());
54    return (AfxDllCanUnloadNow()==S_OK && _AtlModule.GetLockCount()==0) ? S_OK : S_FALSE;
55}
56
57
58//Returns a class factory to create an object of the requested type
59STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
60{
61    return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
62}
63
64
65// DllRegisterServer - Adds entries to the system registry
66STDAPI DllRegisterServer(void)
67{
68    // registers object, typelib and all interfaces in typelib
69    HRESULT hr = _AtlModule.DllRegisterServer();
70    return hr;
71}
72
73
74//DllUnregisterServer - Removes entries from the system registry
75STDAPI DllUnregisterServer(void)
76{
77    HRESULT hr = _AtlModule.DllUnregisterServer();
78    return hr;
79}
80
81//DllInstall - Adds/Removes entries to the system registry per user
82//             per machine.
83STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
84{
85    HRESULT hr = E_FAIL;
86    static const wchar_t szUserSwitch[] = _T("user");
87
88    if (pszCmdLine != NULL)
89    {
90        if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
91        {
92            AtlSetPerUserRegistration(true);
93        }
94    }
95
96    if (bInstall)
97    {
98        hr = DllRegisterServer();
99        if (FAILED(hr))
100        {
101            DllUnregisterServer();
102        }
103    }
104    else
105    {
106        hr = DllUnregisterServer();
107    }
108
109    return hr;
110}
Note: See TracBrowser for help on using the repository browser.