[SHELLEXT][MYDOCS][INF] Add mydocs.dll and .mydocs file extension (#2624)
[reactos.git] / dll / shellext / mydocs / mydocs.cpp
1 /*
2 * PROJECT: mydocs
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: MyDocs implementation
5 * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8 #include "precomp.hpp"
9
10 WINE_DEFAULT_DEBUG_CHANNEL(mydocs);
11
12 BEGIN_OBJECT_MAP(ObjectMap)
13 OBJECT_ENTRY(CLSID_MyDocsDropHandler, CMyDocsDropHandler)
14 END_OBJECT_MAP()
15
16 CComModule gModule;
17 LONG g_ModuleRefCnt = 0;
18
19 STDAPI DllCanUnloadNow(void)
20 {
21 if (g_ModuleRefCnt)
22 return S_FALSE;
23 return gModule.DllCanUnloadNow();
24 }
25
26 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
27 {
28 TRACE("CLSID:%s,IID:%s\n", wine_dbgstr_guid(&rclsid), wine_dbgstr_guid(&riid));
29
30 HRESULT hr = gModule.DllGetClassObject(rclsid, riid, ppv);
31
32 TRACE("-- pointer to class factory: %p\n", *ppv);
33
34 return hr;
35 }
36
37 STDAPI DllRegisterServer(void)
38 {
39 HRESULT hr = gModule.DllRegisterServer(FALSE);
40 if (FAILED_UNEXPECTEDLY(hr))
41 return hr;
42
43 return S_OK;
44 }
45
46 STDAPI DllUnregisterServer(void)
47 {
48 HRESULT hr = gModule.DllUnregisterServer(FALSE);
49 if (FAILED_UNEXPECTEDLY(hr))
50 return hr;
51
52 return S_OK;
53 }
54
55 STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad)
56 {
57 TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
58 if (dwReason == DLL_PROCESS_ATTACH)
59 {
60 gModule.Init(ObjectMap, hInstance, NULL);
61 DisableThreadLibraryCalls(hInstance);
62 }
63 else if (dwReason == DLL_PROCESS_DETACH)
64 {
65 gModule.Term();
66 }
67 return TRUE;
68 }