ReactOS  0.4.15-dev-506-ga3ec01c
mydocs.cpp
Go to the documentation of this file.
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 
11 
12 BEGIN_OBJECT_MAP(ObjectMap)
13  OBJECT_ENTRY(CLSID_MyDocsDropHandler, CMyDocsDropHandler)
15 
18 
19 static BOOL
21 {
22  HANDLE hFile;
26  {
28  return TRUE;
29  }
30  return FALSE;
31 }
32 
33 static HRESULT
35 {
36  WCHAR szTarget[MAX_PATH], szSendToFile[MAX_PATH];
37 
39 
40  StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
41  PathAppendW(szSendToFile, PathFindFileNameW(szTarget));
42  StringCbCatW(szSendToFile, sizeof(szSendToFile), L".mydocs");
43 
44  if (!CreateEmptyFile(szSendToFile))
45  {
46  ERR("CreateEmptyFile(%S, %S) failed!\n", szSendToFile, szTarget);
47  return E_FAIL;
48  }
49 
50  return S_OK;
51 }
52 
53 static HRESULT
55 {
57  SHGFP_TYPE_DEFAULT, pszPath);
58 }
59 
61 {
62  if (g_ModuleRefCnt)
63  return S_FALSE;
64  return gModule.DllCanUnloadNow();
65 }
66 
68 {
69  TRACE("CLSID:%s,IID:%s\n", wine_dbgstr_guid(&rclsid), wine_dbgstr_guid(&riid));
70 
72 
73  TRACE("-- pointer to class factory: %p\n", *ppv);
74 
75  return hr;
76 }
77 
79 {
82  return hr;
83 
84  WCHAR szSendTo[MAX_PATH];
85  hr = GetDefaultUserSendTo(szSendTo);
86  if (SUCCEEDED(hr))
87  CreateSendToMyDocuments(szSendTo);
88 
89  return S_OK;
90 }
91 
93 {
96  return hr;
97 
98  return S_OK;
99 }
100 
102 {
103  TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
105  {
106  gModule.Init(ObjectMap, hInstance, NULL);
108  }
109  else if (dwReason == DLL_PROCESS_DETACH)
110  {
111  gModule.Term();
112  }
113  return TRUE;
114 }
#define STDAPI
Definition: basetyps.h:41
HRESULT DllCanUnloadNow()
Definition: atlbase.h:928
#define REFIID
Definition: guiddef.h:118
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:940
#define CloseHandle
Definition: compat.h:407
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: mydocs.cpp:67
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define OBJECT_ENTRY(clsid, class)
Definition: atlcom.h:653
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
const char * wine_dbgstr_guid(const GUID *guid)
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define E_FAIL
Definition: ddrawi.h:102
DWORD LPVOID fImpLoad
Definition: mydocs.cpp:102
void Term()
Definition: atlbase.h:820
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
STDAPI DllRegisterServer(void)
Definition: mydocs.cpp:78
#define FILE_SHARE_READ
Definition: compat.h:125
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2024
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:797
HINSTANCE hInstance
Definition: charmap.c:20
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define GENERIC_WRITE
Definition: nt_native.h:90
#define S_FALSE
Definition: winerror.h:2357
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:935
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: kbsdll.c:83
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
return TRUE
Definition: mydocs.cpp:113
#define DLL_PROCESS_DETACH
Definition: compat.h:119
DWORD dwReason
Definition: mydocs.cpp:101
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define CSIDL_SENDTO
Definition: shlobj.h:2021
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
STDAPI DllCanUnloadNow(void)
Definition: mydocs.cpp:60
WINE_DEFAULT_DEBUG_CHANNEL(mydocs)
STDAPI_(BOOL) DllMain(HINSTANCE hInstance
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
STDAPI DllUnregisterServer(void)
Definition: mydocs.cpp:92
_In_ HANDLE hFile
Definition: mswsock.h:90
static HRESULT GetDefaultUserSendTo(LPWSTR pszPath)
Definition: mydocs.cpp:54
static HRESULT CreateSendToMyDocuments(LPCWSTR pszSendTo)
Definition: mydocs.cpp:34
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
CComModule gModule
Definition: mydocs.cpp:16
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2709
static BOOL CreateEmptyFile(LPCWSTR pszFile)
Definition: mydocs.cpp:20
#define CreateFileW
Definition: compat.h:409
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2208
#define BEGIN_OBJECT_MAP(x)
Definition: atlcom.h:649
LONG g_ModuleRefCnt
Definition: mydocs.cpp:17
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:945
WCHAR * LPWSTR
Definition: xmlstorage.h:184
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define END_OBJECT_MAP()
Definition: atlcom.h:651