xref: /reactos/dll/shellext/cabview/cabview.cpp (revision b09b5584)
1 /*
2  * PROJECT:     ReactOS CabView Shell Extension
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     DLL entry point
5  * COPYRIGHT:   Copyright 2024 Whindmar Saksit <whindsaks@proton.me>
6  */
7 
8 #include "cabview.h"
9 
10 #include <initguid.h>
11 DEFINE_GUID(CLSID_CabFolder, 0x0CD7A5C0,0x9F37,0x11CE,0xAE,0x65,0x08,0x00,0x2B,0x2E,0x12,0x62);
12 
13 CComModule g_Module;
14 
15 BEGIN_OBJECT_MAP(ObjectMap)
16     OBJECT_ENTRY(CLSID_CabFolder, CCabFolder)
17 END_OBJECT_MAP()
18 
19 EXTERN_C BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
20 {
21     switch (dwReason)
22     {
23         case DLL_PROCESS_ATTACH:
24             DisableThreadLibraryCalls(hInstance);
25             g_Module.Init(ObjectMap, hInstance, NULL);
26             break;
27     }
28 
29     return TRUE;
30 }
31 
32 STDAPI DllCanUnloadNow()
33 {
34     return g_Module.DllCanUnloadNow();
35 }
36 
37 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
38 {
39     return g_Module.DllGetClassObject(rclsid, riid, ppv);
40 }
41 
42 STDAPI DllRegisterServer()
43 {
44     HRESULT hr;
45 
46     hr = g_Module.DllRegisterServer(FALSE);
47     if (FAILED_UNEXPECTEDLY(hr))
48         return hr;
49 
50     hr = g_Module.UpdateRegistryFromResource(IDR_FOLDER, TRUE, NULL);
51     if (FAILED(hr))
52         return hr;
53 
54     return S_OK;
55 }
56 
57 STDAPI DllUnregisterServer()
58 {
59     HRESULT hr1 = g_Module.DllUnregisterServer(FALSE);
60     HRESULT hr2 = g_Module.UpdateRegistryFromResource(IDR_FOLDER, FALSE, NULL);
61     if (FAILED_UNEXPECTEDLY(hr1))
62         return hr1;
63     if (FAILED_UNEXPECTEDLY(hr2))
64         return hr2;
65     return S_OK;
66 }
67