ReactOS 0.4.15-dev-7934-g1dc8d80
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
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
59HRESULT 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 ReleaseStgMedium(&medium);
76 return E_FAIL;
77 }
78 pszSrcList = (LPWSTR) (((byte*) lpdf) + lpdf->pFiles);
79 while (*pszSrcList)
80 {
81 if (StrChrW(pszSrcList, L' ') && cchRemaining > 3)
82 StringCchPrintfExW(pszEnd, cchRemaining, &pszEnd, &cchRemaining, 0, L"\"%ls\" ", pszSrcList);
83 else
84 StringCchPrintfExW(pszEnd, cchRemaining, &pszEnd, &cchRemaining, 0, L"%ls ", pszSrcList);
85
86 pszSrcList += wcslen(pszSrcList) + 1;
87 }
88
89 GlobalUnlock(medium.hGlobal);
90 ReleaseStgMedium(&medium);
91 }
92
94
95 return S_OK;
96}
97
98
99// IPersistFile
101{
102 FIXME ("(%p)\n", this);
103 return E_NOTIMPL;
104}
105
107{
108 FIXME ("(%p)\n", this);
109 return E_NOTIMPL;
110}
111
113{
115 sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
116 memcpy(sPathTarget, pszFileName, (len + 1) * sizeof(WCHAR));
117 return S_OK;
118}
119
121{
122 FIXME ("(%p)\n", this);
123 return E_NOTIMPL;
124}
125
127{
128 FIXME ("(%p)\n", this);
129 return E_NOTIMPL;
130}
131
132/************************************************************************
133 * CFSFolder::GetClassID
134 */
136{
137 TRACE ("(%p)\n", this);
138
139 if (!lpClassId)
140 return E_POINTER;
141
142 *lpClassId = *pclsid;
143
144 return S_OK;
145}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define CF_HDROP
Definition: constants.h:410
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
STDMETHOD() GetCurFile(LPOLESTR *ppszFileName) override
STDMETHOD() Drop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
STDMETHOD() SaveCompleted(LPCOLESTR pszFileName) override
STDMETHOD() GetClassID(CLSID *lpClassId) override
STDMETHOD() DragLeave() override
STDMETHOD() Save(LPCOLESTR pszFileName, BOOL fRemember) override
STDMETHOD() Load(LPCOLESTR pszFileName, DWORD dwMode) override
STDMETHOD() IsDirty() override
STDMETHOD() DragEnter(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
STDMETHOD() DragOver(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468
#define MAX_PATH
Definition: compat.h:34
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
#define pt(x, y)
Definition: drawing.c:79
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static LPOLESTR
Definition: stg_prop.c:27
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define strlenW(s)
Definition: unicode.h:28
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2402
struct _DROPFILES * LPDROPFILES
#define _countof(array)
Definition: sndvol32.h:68
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
DWORD pFiles
Definition: shlobj.h:2292
Definition: dsound.c:943
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define WINAPI
Definition: msvc.h:6
#define E_POINTER
Definition: winerror.h:2365
#define SW_SHOWNORMAL
Definition: winuser.h:770
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184