ReactOS  0.4.14-dev-854-gb9426a3
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 
12 BEGIN_OBJECT_MAP(ObjectMap)
13  OBJECT_ENTRY(CLSID_DeskLinkDropHandler, CDeskLinkDropHandler)
15 
18 
20 {
21  if (g_ModuleRefCnt)
22  return S_FALSE;
23  return gModule.DllCanUnloadNow();
24 }
25 
27 {
28  TRACE("CLSID:%s,IID:%s\n", wine_dbgstr_guid(&rclsid), wine_dbgstr_guid(&riid));
29 
31 
32  TRACE("-- pointer to class factory: %p\n", *ppv);
33 
34  return hr;
35 }
36 
38 {
41  return hr;
42 
43  return S_OK;
44 }
45 
47 {
50  return hr;
51 
52  return S_OK;
53 }
54 
55 HRESULT
57  LPCWSTR pszLinkPath,
58  LPCWSTR pszTargetPath OPTIONAL,
59  LPCITEMIDLIST pidlTarget OPTIONAL,
60  LPCWSTR pszArg OPTIONAL,
62  LPCWSTR pszIconPath OPTIONAL,
63  INT iIconNr OPTIONAL,
64  LPCWSTR pszComment OPTIONAL)
65 {
67  HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL,
68  CLSCTX_INPROC_SERVER,
69  IID_PPV_ARG(IShellLinkW, &psl));
71  return hr;
72 
73  if (pszTargetPath)
74  {
75  hr = psl->SetPath(pszTargetPath);
77  return hr;
78  }
79  else if (pidlTarget)
80  {
81  hr = psl->SetIDList(pidlTarget);
83  return hr;
84  }
85  else
86  {
87  ERR("invalid argument\n");
88  return E_INVALIDARG;
89  }
90 
91  if (pszArg)
92  hr = psl->SetArguments(pszArg);
93 
94  if (pszDir)
95  hr = psl->SetWorkingDirectory(pszDir);
96 
97  if (pszIconPath)
98  hr = psl->SetIconLocation(pszIconPath, iIconNr);
99 
100  if (pszComment)
101  hr = psl->SetDescription(pszComment);
102 
104  hr = psl->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf));
105  if (FAILED_UNEXPECTEDLY(hr))
106  return hr;
107 
108  hr = ppf->Save(pszLinkPath, TRUE);
109  if (FAILED_UNEXPECTEDLY(hr))
110  return hr;
111 
112  return hr;
113 }
114 
116 {
117  TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad);
119  {
120  gModule.Init(ObjectMap, hInstance, NULL);
122  }
123  else if (dwReason == DLL_PROCESS_DETACH)
124  {
125  gModule.Term();
126  }
127  return TRUE;
128 }
#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
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: sendmail.cpp:26
#define OBJECT_ENTRY(clsid, class)
Definition: atlcom.h:653
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
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 DLL_PROCESS_ATTACH
Definition: compat.h:120
#define IID_PPV_ARG(Itype, ppType)
STDAPI DllUnregisterServer(void)
Definition: sendmail.cpp:46
int32_t INT
Definition: typedefs.h:56
CComModule gModule
Definition: sendmail.cpp:16
void Term()
Definition: atlbase.h:820
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:56
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 S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
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
#define DLL_PROCESS_DETACH
Definition: compat.h:119
DWORD dwReason
Definition: sendmail.cpp:115
STDAPI_(BOOL) DllMain(HINSTANCE hInstance
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
_In_ LPCSTR pszDir
Definition: shellapi.h:580
unsigned long DWORD
Definition: ntddk_ex.h:95
STDAPI DllCanUnloadNow(void)
Definition: sendmail.cpp:19
DWORD LPVOID fImpLoad
Definition: sendmail.cpp:116
WINE_DEFAULT_DEBUG_CHANNEL(sendmail)
LONG g_ModuleRefCnt
Definition: sendmail.cpp:17
return TRUE
Definition: sendmail.cpp:127
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
STDAPI DllRegisterServer(void)
Definition: sendmail.cpp:37
#define BEGIN_OBJECT_MAP(x)
Definition: atlcom.h:649
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:945
#define END_OBJECT_MAP()
Definition: atlcom.h:651
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68