ReactOS  0.4.15-dev-1177-g6cb3b62
CexeDropHandler.cpp
Go to the documentation of this file.
1 /*
2  * executable drop target handler
3  *
4  * Copyright 2014 Huw Campbell
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #include <precomp.h>
22 
24 
26 {
27  pclsid = (CLSID *)&CLSID_ExeDropHandler;
28 }
29 
31 {
32 
33 }
34 
35 // IDropTarget
36 HRESULT WINAPI CExeDropHandler::DragEnter(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
37 {
38  TRACE ("(%p)\n", this);
39  if (*pdwEffect == DROPEFFECT_NONE)
40  return S_OK;
41 
42  *pdwEffect = DROPEFFECT_COPY;
43  return S_OK;
44 }
45 
47 {
48  TRACE ("(%p)\n", this);
49  *pdwEffect = DROPEFFECT_COPY;
50  return S_OK;
51 }
52 
54 {
55  TRACE ("(%p)\n", this);
56  return S_OK;
57 }
58 
59 HRESULT WINAPI CExeDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
60 {
61  TRACE ("(%p)\n", this);
62  FORMATETC fmt;
63  STGMEDIUM medium;
64  LPWSTR pszSrcList;
65  InitFormatEtc (fmt, CF_HDROP, TYMED_HGLOBAL);
66  WCHAR wszBuf[MAX_PATH * 2 + 8], *pszEnd = wszBuf;
67  size_t cchRemaining = _countof(wszBuf);
68 
69  if (SUCCEEDED(pDataObject->GetData(&fmt, &medium)) /* && SUCCEEDED(pDataObject->GetData(&fmt2, &medium))*/)
70  {
71  LPDROPFILES lpdf = (LPDROPFILES) GlobalLock(medium.hGlobal);
72  if (!lpdf)
73  {
74  ERR("Error locking global\n");
75  return E_FAIL;
76  }
77  pszSrcList = (LPWSTR) (((byte*) lpdf) + lpdf->pFiles);
78  while (*pszSrcList)
79  {
80  if (StrChrW(pszSrcList, L' ') && cchRemaining > 3)
81  StringCchPrintfExW(pszEnd, cchRemaining, &pszEnd, &cchRemaining, 0, L"\"%ls\" ", pszSrcList);
82  else
83  StringCchPrintfExW(pszEnd, cchRemaining, &pszEnd, &cchRemaining, 0, L"%ls ", pszSrcList);
84 
85  pszSrcList += wcslen(pszSrcList) + 1;
86  }
87  }
88 
90 
91  return S_OK;
92 }
93 
94 
95 // IPersistFile
97 {
98  FIXME ("(%p)\n", this);
99  return E_NOTIMPL;
100 }
101 
103 {
104  FIXME ("(%p)\n", this);
105  return E_NOTIMPL;
106 }
107 
109 {
111  sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
112  memcpy(sPathTarget, pszFileName, (len + 1) * sizeof(WCHAR));
113  return S_OK;
114 }
115 
117 {
118  FIXME ("(%p)\n", this);
119  return E_NOTIMPL;
120 }
121 
123 {
124  FIXME ("(%p)\n", this);
125  return E_NOTIMPL;
126 }
127 
128 /************************************************************************
129  * CFSFolder::GetClassID
130  */
132 {
133  TRACE ("(%p)\n", this);
134 
135  if (!lpClassId)
136  return E_POINTER;
137 
138  *lpClassId = *pclsid;
139 
140  return S_OK;
141 }
struct _DROPFILES * LPDROPFILES
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
#define pt(x, y)
Definition: drawing.c:79
virtual HRESULT WINAPI SaveCompleted(LPCOLESTR pszFileName)
const char * fmt
Definition: wsprintf.c:30
virtual HRESULT WINAPI DragLeave()
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
virtual HRESULT WINAPI Load(LPCOLESTR pszFileName, DWORD dwMode)
static LPOLESTR
Definition: stg_prop.c:27
#define E_FAIL
Definition: ddrawi.h:102
virtual HRESULT WINAPI Save(LPCOLESTR pszFileName, BOOL fRemember)
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
WINE_DEFAULT_DEBUG_CHANNEL(shell)
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
virtual HRESULT WINAPI GetClassID(CLSID *lpClassId)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
virtual HRESULT WINAPI DragEnter(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
smooth NULL
Definition: ftsmooth.c:416
#define CF_HDROP
Definition: constants.h:410
virtual HRESULT WINAPI IsDirty()
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
#define SW_SHOWNORMAL
Definition: winuser.h:764
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
virtual HRESULT WINAPI GetCurFile(LPOLESTR *ppszFileName)
#define E_NOTIMPL
Definition: ddrawi.h:99
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468
unsigned int UINT
Definition: ndis.h:50
virtual HRESULT WINAPI DragOver(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274
virtual HRESULT WINAPI Drop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
Definition: dsound.c:943
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:49