2 * File System Bind Data object to use as parameter for the bind context to
3 * IShellFolder_ParseDisplayName
5 * Copyright 2003 Rolf Kalbermatter
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
34 #include "shell32_main.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(pidl);
40 /***********************************************************************
41 * IFileSystemBindData implementation
45 const IFileSystemBindDataVtbl *lpVtbl;
47 WIN32_FIND_DATAW findFile;
48 } IFileSystemBindDataImpl;
50 static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData *, REFIID, LPVOID*);
51 static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *);
52 static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *);
53 static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *, WIN32_FIND_DATAW *);
54 static HRESULT WINAPI IFileSystemBindData_fnSetFindData(IFileSystemBindData *, const WIN32_FIND_DATAW *);
56 static const IFileSystemBindDataVtbl sbvt =
58 IFileSystemBindData_fnQueryInterface,
59 IFileSystemBindData_fnAddRef,
60 IFileSystemBindData_fnRelease,
61 IFileSystemBindData_fnSetFindData,
62 IFileSystemBindData_fnGetFindData,
65 static const WCHAR wFileSystemBindData[] = {
66 'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0};
68 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
70 IFileSystemBindDataImpl *sb;
71 HRESULT ret = E_OUTOFMEMORY;
73 TRACE("%p, %p\n", pfd, ppV);
80 sb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IFileSystemBindDataImpl));
86 IFileSystemBindData_fnSetFindData((IFileSystemBindData*)sb, pfd);
88 ret = CreateBindCtx(0, ppV);
93 bindOpts.cbStruct = sizeof(BIND_OPTS);
94 bindOpts.grfFlags = 0;
95 bindOpts.grfMode = STGM_CREATE;
96 bindOpts.dwTickCountDeadline = 0;
97 IBindCtx_SetBindOptions(*ppV, &bindOpts);
98 IBindCtx_RegisterObjectParam(*ppV, (LPOLESTR)wFileSystemBindData, (LPUNKNOWN)sb);
100 IFileSystemBindData_Release((IFileSystemBindData*)sb);
103 HeapFree(GetProcessHeap(), 0, sb);
107 HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd)
110 IFileSystemBindData *pfsbd = NULL;
113 TRACE("%p, %p\n", pbc, pfd);
118 ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk);
121 ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd);
124 ret = IFileSystemBindData_GetFindData(pfsbd, pfd);
125 IFileSystemBindData_Release(pfsbd);
127 IUnknown_Release(pUnk);
132 HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd)
135 IFileSystemBindData *pfsbd = NULL;
138 TRACE("%p, %p\n", pbc, pfd);
140 ret = IBindCtx_GetObjectParam(pbc, (LPOLESTR)wFileSystemBindData, &pUnk);
143 ret = IUnknown_QueryInterface(pUnk, &IID_IFileSystemBindData, (LPVOID *)&pfsbd);
146 ret = IFileSystemBindData_SetFindData(pfsbd, pfd);
147 IFileSystemBindData_Release(pfsbd);
149 IUnknown_Release(pUnk);
154 static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(
155 IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
157 IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
158 TRACE("(%p)->(\n\tIID:\t%s, %p)\n", This, debugstr_guid(riid), ppV);
162 if (IsEqualIID(riid, &IID_IUnknown))
164 else if (IsEqualIID(riid, &IID_IFileSystemBindData))
165 *ppV = (IFileSystemBindData*)This;
169 IUnknown_AddRef((IUnknown*)(*ppV));
170 TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
173 TRACE("-- Interface: E_NOINTERFACE\n");
174 return E_NOINTERFACE;
177 static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface)
179 IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
180 ULONG refCount = InterlockedIncrement(&This->ref);
182 TRACE("(%p)->(count=%i)\n", This, refCount - 1);
187 static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface)
189 IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
190 ULONG refCount = InterlockedDecrement(&This->ref);
192 TRACE("(%p)->(count=%i)\n", This, refCount + 1);
196 TRACE(" destroying ISFBindPidl(%p)\n",This);
197 HeapFree(GetProcessHeap(), 0, This);
202 static HRESULT WINAPI IFileSystemBindData_fnGetFindData(
203 IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
205 IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
206 TRACE("(%p), %p\n", This, pfd);
211 memcpy(pfd, &This->findFile, sizeof(WIN32_FIND_DATAW));
215 static HRESULT WINAPI IFileSystemBindData_fnSetFindData(
216 IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
218 IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface;
219 TRACE("(%p), %p\n", This, pfd);
222 memcpy(&This->findFile, pfd, sizeof(WIN32_FIND_DATAW));
224 memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));