ReactOS 0.4.15-dev-6694-g4ba8af9
clipboard.c File Reference
#include <windef.h>
#include <winbase.h>
#include <shlobj.h>
#include <wine/debug.h>
#include <wine/unicode.h>
Include dependency graph for clipboard.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
HGLOBAL RenderHDROP (LPITEMIDLIST pidlRoot, LPITEMIDLIST *apidl, UINT cidl)
 
HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST *apidl, UINT cidl)
 
HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST *apidl, UINT cidl)
 
HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST *apidl, UINT cidl)
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 39 of file clipboard.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 38 of file clipboard.c.

Function Documentation

◆ RenderFILENAMEA()

HGLOBAL RenderFILENAMEA ( LPITEMIDLIST  pidlRoot,
LPITEMIDLIST apidl,
UINT  cidl 
)

Definition at line 188 of file clipboard.c.

189{
190 int size = 0;
191 char szTemp[MAX_PATH], *szFileName;
192 LPITEMIDLIST pidl;
193 HGLOBAL hGlobal;
195
196 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
197
198 /* get path of combined pidl */
199 pidl = ILCombine(pidlRoot, apidl[0]);
200 if (!pidl)
201 return 0;
202
203 bSuccess = SHGetPathFromIDListA(pidl, szTemp);
204 SHFree(pidl);
205 if (!bSuccess)
206 return 0;
207
208 size = strlen(szTemp) + 1;
209
210 /* fill the structure */
211 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
212 if(!hGlobal) return hGlobal;
213 szFileName = GlobalLock(hGlobal);
214 memcpy(szFileName, szTemp, size);
215 GlobalUnlock(hGlobal);
216
217 return hGlobal;
218}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define MAX_PATH
Definition: compat.h:34
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:703
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
Definition: pidl.c:1282
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define TRACE(s)
Definition: solgame.cpp:4
#define GHND
Definition: winbase.h:297
#define GMEM_SHARE
Definition: winbase.h:305

Referenced by CIDLDataObj::Initialize().

◆ RenderFILENAMEW()

HGLOBAL RenderFILENAMEW ( LPITEMIDLIST  pidlRoot,
LPITEMIDLIST apidl,
UINT  cidl 
)

Definition at line 220 of file clipboard.c.

221{
222 int size = 0;
223 WCHAR szTemp[MAX_PATH], *szFileName;
224 LPITEMIDLIST pidl;
225 HGLOBAL hGlobal;
227
228 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
229
230 /* get path of combined pidl */
231 pidl = ILCombine(pidlRoot, apidl[0]);
232 if (!pidl)
233 return 0;
234
235 bSuccess = SHGetPathFromIDListW(pidl, szTemp);
236 SHFree(pidl);
237 if (!bSuccess)
238 return 0;
239
240 size = (strlenW(szTemp)+1) * sizeof(WCHAR);
241
242 /* fill the structure */
243 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
244 if(!hGlobal) return hGlobal;
245 szFileName = GlobalLock(hGlobal);
246 memcpy(szFileName, szTemp, size);
247 GlobalUnlock(hGlobal);
248
249 return hGlobal;
250}
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1298
#define strlenW(s)
Definition: unicode.h:28
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CIDLDataObj::Initialize().

◆ RenderHDROP()

HGLOBAL RenderHDROP ( LPITEMIDLIST  pidlRoot,
LPITEMIDLIST apidl,
UINT  cidl 
)

Definition at line 54 of file clipboard.c.

55{
56 UINT i;
57#ifdef __REACTOS__
58 int size = 0;
59#else
60 int rootlen = 0,size = 0;
61 WCHAR wszRootPath[MAX_PATH];
62#endif
64 HGLOBAL hGlobal = NULL;
65 DROPFILES *pDropFiles;
66 int offset;
67#ifdef __REACTOS__
68 LPITEMIDLIST *pidls;
69#endif
70
71 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
72
73#ifdef __REACTOS__
74 pidls = (LPITEMIDLIST *)HeapAlloc(GetProcessHeap(), 0, cidl * sizeof(*pidls));
75 if (!pidls)
76 goto cleanup;
77#endif
78
79 /* get the size needed */
80 size = sizeof(DROPFILES);
81
82#ifndef __REACTOS__
83 SHGetPathFromIDListW(pidlRoot, wszRootPath);
84 PathAddBackslashW(wszRootPath);
85 rootlen = strlenW(wszRootPath);
86#endif
87
88 for (i=0; i<cidl;i++)
89 {
90#ifdef __REACTOS__
91 pidls[i] = ILCombine(pidlRoot, apidl[i]);
93 size += (wcslen(wszFileName) + 1) * sizeof(WCHAR);
94#else
96 size += (rootlen + strlenW(wszFileName) + 1) * sizeof(WCHAR);
97#endif
98 }
99
100 size += sizeof(WCHAR);
101
102 /* Fill the structure */
103 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
104#ifdef __REACTOS__
105 if(!hGlobal) goto cleanup;
106#else
107 if(!hGlobal) return hGlobal;
108#endif
109
110 pDropFiles = GlobalLock(hGlobal);
111 offset = (sizeof(DROPFILES) + sizeof(WCHAR) - 1) / sizeof(WCHAR);
112 pDropFiles->pFiles = offset * sizeof(WCHAR);
113 pDropFiles->fWide = TRUE;
114
115#ifndef __REACTOS__
116 strcpyW(wszFileName, wszRootPath);
117#endif
118
119 for (i=0; i<cidl;i++)
120 {
121
122#ifdef __REACTOS__
124 wcscpy(((WCHAR*)pDropFiles)+offset, wszFileName);
125 offset += wcslen(wszFileName) + 1;
126 ILFree(pidls[i]);
127#else
128 _ILSimpleGetTextW(apidl[i], wszFileName + rootlen, MAX_PATH - rootlen);
129 strcpyW(((WCHAR*)pDropFiles)+offset, wszFileName);
130 offset += strlenW(wszFileName) + 1;
131#endif
132 }
133
134 ((WCHAR*)pDropFiles)[offset] = 0;
135 GlobalUnlock(hGlobal);
136
137#ifdef __REACTOS__
138cleanup:
139 if(pidls)
140 HeapFree(GetProcessHeap(), 0, pidls);
141#endif
142
143 return hGlobal;
144}
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static void cleanup(void)
Definition: main.c:1335
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int UINT
Definition: ndis.h:50
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:929
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2111
#define strcpyW(d, s)
Definition: unicode.h:29
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct _DROPFILES DROPFILES
DWORD pFiles
Definition: shlobj.h:2163
BOOL fWide
Definition: shlobj.h:2166

Referenced by CIDLDataObj::Initialize().

◆ RenderSHELLIDLIST()

HGLOBAL RenderSHELLIDLIST ( LPITEMIDLIST  pidlRoot,
LPITEMIDLIST apidl,
UINT  cidl 
)

Definition at line 146 of file clipboard.c.

147{
148 UINT i;
149 int offset = 0, sizePidl, size;
150 HGLOBAL hGlobal;
151 LPIDA pcida;
152
153 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
154
155 /* get the size needed */
156 size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */
157 size += ILGetSize (pidlRoot); /* root pidl */
158 for(i=0; i<cidl; i++)
159 {
160 size += ILGetSize(apidl[i]); /* child pidls */
161 }
162
163 /* fill the structure */
164 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
165 if(!hGlobal) return hGlobal;
166 pcida = GlobalLock (hGlobal);
167 pcida->cidl = cidl;
168
169 /* root pidl */
170 offset = sizeof(CIDA) + sizeof (UINT)*(cidl);
171 pcida->aoffset[0] = offset; /* first element */
172 sizePidl = ILGetSize (pidlRoot);
173 memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl);
174 offset += sizePidl;
175
176 for(i=0; i<cidl; i++) /* child pidls */
177 {
178 pcida->aoffset[i+1] = offset;
179 sizePidl = ILGetSize(apidl[i]);
180 memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl);
181 offset += sizePidl;
182 }
183
184 GlobalUnlock(hGlobal);
185 return hGlobal;
186}
#define ILGetSize
Definition: shellclasses.h:638
Definition: shlobj.h:503
UINT aoffset[1]
Definition: shlobj.h:504
UINT cidl
Definition: shlobj.h:503
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by CIDLDataObj::Initialize().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )