ReactOS  0.4.15-dev-313-g8fde48b
sendmail.cpp File Reference
#include "precomp.hpp"
Include dependency graph for sendmail.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (sendmail)
 
static BOOL CreateEmptyFile (LPCWSTR pszFile)
 
static HRESULT CreateSendToDeskLink (LPCWSTR pszSendTo)
 
static HRESULT GetDefaultUserSendTo (LPWSTR pszPath)
 
STDAPI DllCanUnloadNow (void)
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
STDAPI DllRegisterServer (void)
 
STDAPI DllUnregisterServer (void)
 
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)
 
 STDAPI_ (BOOL) DllMain(HINSTANCE hInstance
 
 if (dwReason==DLL_PROCESS_ATTACH)
 

Variables

CComModule gModule
 
LONG g_ModuleRefCnt = 0
 
HINSTANCE g_hModule
 
DWORD dwReason
 
DWORD LPVOID fImpLoad
 
return TRUE
 

Function Documentation

◆ CreateEmptyFile()

static BOOL CreateEmptyFile ( LPCWSTR  pszFile)
static

Definition at line 21 of file sendmail.cpp.

22 {
23  HANDLE hFile;
27  {
29  return TRUE;
30  }
31  return FALSE;
32 }
#define CloseHandle
Definition: compat.h:407
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_In_ HANDLE hFile
Definition: mswsock.h:90
return TRUE
Definition: sendmail.cpp:174
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileW
Definition: compat.h:409

Referenced by CreateSendToDeskLink().

◆ CreateSendToDeskLink()

static HRESULT CreateSendToDeskLink ( LPCWSTR  pszSendTo)
static

Definition at line 35 of file sendmail.cpp.

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 }
static BOOL CreateEmptyFile(LPCWSTR pszFile)
Definition: sendmail.cpp:21
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
#define IDS_DESKLINK
Definition: resource.h:13
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
HINSTANCE g_hModule
Definition: sendmail.cpp:18
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166

Referenced by DllRegisterServer().

◆ CreateShellLink()

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 at line 102 of file sendmail.cpp.

111 {
113  HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL,
114  CLSCTX_INPROC_SERVER,
115  IID_PPV_ARG(IShellLinkW, &psl));
116  if (FAILED_UNEXPECTEDLY(hr))
117  return hr;
118 
119  if (pszTargetPath)
120  {
121  hr = psl->SetPath(pszTargetPath);
122  if (FAILED_UNEXPECTEDLY(hr))
123  return hr;
124  }
125  else if (pidlTarget)
126  {
127  hr = psl->SetIDList(pidlTarget);
128  if (FAILED_UNEXPECTEDLY(hr))
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));
151  if (FAILED_UNEXPECTEDLY(hr))
152  return hr;
153 
154  hr = ppf->Save(pszLinkPath, TRUE);
155  if (FAILED_UNEXPECTEDLY(hr))
156  return hr;
157 
158  return hr;
159 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
_In_ LPCSTR pszDir
Definition: shellapi.h:580
return TRUE
Definition: sendmail.cpp:174
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:110

Referenced by CDeskLinkDropHandler::Drop().

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 60 of file sendmail.cpp.

61 {
62  if (g_ModuleRefCnt)
63  return S_FALSE;
64  return gModule.DllCanUnloadNow();
65 }
HRESULT DllCanUnloadNow()
Definition: atlbase.h:928
CComModule gModule
Definition: sendmail.cpp:16
#define S_FALSE
Definition: winerror.h:2357
LONG g_ModuleRefCnt
Definition: sendmail.cpp:17

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 67 of file sendmail.cpp.

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 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
const char * wine_dbgstr_guid(const GUID *guid)
CComModule gModule
Definition: sendmail.cpp:16
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:935
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 78 of file sendmail.cpp.

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 }
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:940
HRESULT hr
Definition: shlfolder.c:183
static HRESULT CreateSendToDeskLink(LPCWSTR pszSendTo)
Definition: sendmail.cpp:35
CComModule gModule
Definition: sendmail.cpp:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
#define S_OK
Definition: intsafe.h:59
static HRESULT GetDefaultUserSendTo(LPWSTR pszPath)
Definition: sendmail.cpp:54
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 92 of file sendmail.cpp.

93 {
96  return hr;
97 
98  return S_OK;
99 }
HRESULT hr
Definition: shlfolder.c:183
CComModule gModule
Definition: sendmail.cpp:16
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define S_OK
Definition: intsafe.h:59
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:945

◆ GetDefaultUserSendTo()

static HRESULT GetDefaultUserSendTo ( LPWSTR  pszPath)
static

Definition at line 54 of file sendmail.cpp.

55 {
57  SHGFP_TYPE_DEFAULT, pszPath);
58 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
smooth NULL
Definition: ftsmooth.c:416
#define CSIDL_SENDTO
Definition: shlobj.h:2021
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2208

Referenced by DllRegisterServer().

◆ if()

Definition at line 164 of file sendmail.cpp.

165  {
167  gModule.Init(ObjectMap, hInstance, NULL);
169  }
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
CComModule gModule
Definition: sendmail.cpp:16
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:797
HINSTANCE hInstance
Definition: charmap.c:20
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE g_hModule
Definition: sendmail.cpp:18

◆ STDAPI_()

STDAPI_ ( BOOL  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( sendmail  )

Variable Documentation

◆ dwReason

DWORD dwReason

Definition at line 161 of file sendmail.cpp.

◆ fImpLoad

DWORD LPVOID fImpLoad
Initial value:
{
TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad)
HINSTANCE hInstance
Definition: charmap.c:20
DWORD dwReason
Definition: sendmail.cpp:161
#define TRACE(s)
Definition: solgame.cpp:4
DWORD LPVOID fImpLoad
Definition: sendmail.cpp:162

Definition at line 162 of file sendmail.cpp.

◆ g_hModule

HINSTANCE g_hModule

Definition at line 18 of file sendmail.cpp.

Referenced by CreateSendToDeskLink(), and if().

◆ g_ModuleRefCnt

LONG g_ModuleRefCnt = 0

Definition at line 17 of file sendmail.cpp.

Referenced by DllCanUnloadNow().

◆ gModule

◆ TRUE

return TRUE

Definition at line 174 of file sendmail.cpp.

Referenced by CreateEmptyFile(), and CreateShellLink().