ReactOS 0.4.15-dev-8096-ga0eec98
sendmail.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: sendmail
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: DeskLink implementation
5 * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "precomp.hpp"
9
11
12BEGIN_OBJECT_MAP(ObjectMap)
13 OBJECT_ENTRY(CLSID_DeskLinkDropHandler, CDeskLinkDropHandler)
15
19
20static BOOL
22{
27 {
29 return TRUE;
30 }
31 return FALSE;
32}
33
34static HRESULT
36{
37 WCHAR szTarget[MAX_PATH], szSendToFile[MAX_PATH];
38
39 LoadStringW(g_hModule, IDS_DESKLINK, szTarget, _countof(szTarget));
40 StringCbCatW(szTarget, sizeof(szTarget), L".DeskLink");
41
42 StringCbCopyW(szSendToFile, sizeof(szSendToFile), pszSendTo);
43 PathAppendW(szSendToFile, szTarget);
44
45 if (!CreateEmptyFile(szSendToFile))
46 {
47 ERR("CreateEmptyFile('%ls')\n", szSendToFile);
48 return E_FAIL;
49 }
50 return S_OK;
51}
52
53static HRESULT
55{
57 SHGFP_TYPE_DEFAULT, pszPath);
58}
59
61{
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 CreateSendToDeskLink(szSendTo);
88
89 return S_OK;
90}
91
93{
96 return hr;
97
98 return S_OK;
99}
100
103 LPCWSTR pszLinkPath,
104 LPCWSTR pszTargetPath OPTIONAL,
105 LPCITEMIDLIST pidlTarget OPTIONAL,
106 LPCWSTR pszArg OPTIONAL,
108 LPCWSTR pszIconPath OPTIONAL,
109 INT iIconNr OPTIONAL,
110 LPCWSTR pszComment OPTIONAL)
111{
113 HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL,
114 CLSCTX_INPROC_SERVER,
115 IID_PPV_ARG(IShellLinkW, &psl));
117 return hr;
118
119 if (pszTargetPath)
120 {
121 hr = psl->SetPath(pszTargetPath);
123 return hr;
124 }
125 else if (pidlTarget)
126 {
127 hr = psl->SetIDList(pidlTarget);
129 return hr;
130 }
131 else
132 {
133 ERR("invalid argument\n");
134 return E_INVALIDARG;
135 }
136
137 if (pszArg)
138 hr = psl->SetArguments(pszArg);
139
140 if (pszDir)
141 hr = psl->SetWorkingDirectory(pszDir);
142
143 if (pszIconPath)
144 hr = psl->SetIconLocation(pszIconPath, iIconNr);
145
146 if (pszComment)
147 hr = psl->SetDescription(pszComment);
148
150 hr = psl->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf));
152 return hr;
153
154 hr = ppf->Save(pszLinkPath, TRUE);
156 return hr;
157
158 return hr;
159}
160
162{
163 TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
165 {
167 gModule.Init(ObjectMap, hInstance, NULL);
169 }
170 else if (dwReason == DLL_PROCESS_DETACH)
171 {
172 gModule.Term();
173 }
174 return TRUE;
175}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define STDAPI_(t)
Definition: basetyps.h:42
#define STDAPI
Definition: basetyps.h:41
#define ERR(fmt,...)
Definition: debug.h:113
HINSTANCE hInstance
Definition: charmap.c:19
void Term()
Definition: atlbase.h:916
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:1037
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:1047
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:886
HRESULT DllCanUnloadNow()
Definition: atlbase.h:1030
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:1042
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define IDS_DESKLINK
Definition: resource.h:13
#define CloseHandle
Definition: compat.h:739
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
BOOL WINAPI DllMain(IN HINSTANCE hinstDLL, IN DWORD dwReason, IN LPVOID lpvReserved)
Definition: kbsdll.c:95
#define END_OBJECT_MAP()
Definition: atlcom.h:691
#define OBJECT_ENTRY(clsid, class)
Definition: atlcom.h:693
#define BEGIN_OBJECT_MAP(x)
Definition: atlcom.h:689
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
HRESULT CreateShellLink(LPCWSTR pszLinkPath, LPCWSTR pszTargetPath OPTIONAL, LPCITEMIDLIST pidlTarget OPTIONAL, LPCWSTR pszArg OPTIONAL, LPCWSTR pszDir OPTIONAL, LPCWSTR pszIconPath OPTIONAL, INT iIconNr OPTIONAL, LPCWSTR pszComment OPTIONAL)
Definition: sendmail.cpp:102
STDAPI DllRegisterServer(void)
Definition: sendmail.cpp:78
static BOOL CreateEmptyFile(LPCWSTR pszFile)
Definition: sendmail.cpp:21
HINSTANCE g_hModule
Definition: sendmail.cpp:18
DWORD LPVOID fImpLoad
Definition: sendmail.cpp:162
LONG g_ModuleRefCnt
Definition: sendmail.cpp:17
STDAPI DllUnregisterServer(void)
Definition: sendmail.cpp:92
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: sendmail.cpp:67
return TRUE
Definition: sendmail.cpp:174
CComModule gModule
Definition: sendmail.cpp:16
DWORD dwReason
Definition: sendmail.cpp:161
static HRESULT GetDefaultUserSendTo(LPWSTR pszPath)
Definition: sendmail.cpp:54
static HRESULT CreateSendToDeskLink(LPCWSTR pszSendTo)
Definition: sendmail.cpp:35
STDAPI DllCanUnloadNow(void)
Definition: sendmail.cpp:60
_In_ LPCSTR pszDir
Definition: shellapi.h:584
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_SENDTO
Definition: shlobj.h:2168
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2136
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
int32_t INT
Definition: typedefs.h:58
#define S_FALSE
Definition: winerror.h:2357
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IID_PPV_ARG(Itype, ppType)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185