1 /////////////////////////////////////////////////////////////////////////////
2 // ShellExtension.cpp : Implementation of DLL Exports.
4 /////////////////////////////////////////////////////////////////////////////
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or (at
9 // your option) any later version.
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /////////////////////////////////////////////////////////////////////////////
20 // Look at http://www.codeproject.com/shell/ for excellent guide
21 // to Windows Shell programming by Michael Dunn.
25 // Note: Proxy/Stub Information
26 // To build a separate proxy/stub DLL,
27 // run nmake -f ShellExtensionps.mk in the project directory.
32 #include "ShellExtension.h"
33 #include "ShellExtension_i.c"
36 class CWinMergeShellModule : public ATL::CAtlDllModuleT< CWinMergeShellModule >
39 DECLARE_LIBID(LIBID_SHELLEXTENSIONLib)
40 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_WINMERGESHELL, "{06029E17-28B5-456A-B866-4E79D98612FD}")
43 class CWinMergeShellModule _AtlModule;
46 extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
49 return _AtlModule.DllMain(dwReason, lpReserved);
52 // Used to determine whether the DLL can be unloaded by OLE.
53 _Use_decl_annotations_
54 STDAPI DllCanUnloadNow(void)
56 return _AtlModule.DllCanUnloadNow();
59 // Returns a class factory to create an object of the requested type.
60 _Use_decl_annotations_
61 STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
63 return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
66 // DllRegisterServer - Adds entries to the system registry.
67 _Use_decl_annotations_
68 STDAPI DllRegisterServer(void)
70 // registers object, typelib and all interfaces in typelib
71 HRESULT hr = _AtlModule.DllRegisterServer();
75 // DllUnregisterServer - Removes entries from the system registry.
76 _Use_decl_annotations_
77 STDAPI DllUnregisterServer(void)
79 HRESULT hr = _AtlModule.DllUnregisterServer();
83 // DllInstall - Adds/Removes entries to the system registry per user per machine.
84 STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine)
87 static const wchar_t szUserSwitch[] = L"user";
89 if (pszCmdLine != nullptr)
91 if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
93 ATL::AtlSetPerUserRegistration(true);
99 hr = DllRegisterServer();
102 DllUnregisterServer();
107 hr = DllUnregisterServer();