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"
33 #include "shell32_main.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(pidl);
39 /***********************************************************************
40 * IFileSystemBindData implementation
44 IFileSystemBindData IFileSystemBindData_iface;
46 WIN32_FIND_DATAW findFile;
49 static inline FileSystemBindData *impl_from_IFileSystemBindData(IFileSystemBindData *iface)
51 return CONTAINING_RECORD(iface, FileSystemBindData, IFileSystemBindData_iface);
54 static HRESULT WINAPI FileSystemBindData_QueryInterface(
55 IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
57 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
59 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppV);
63 if (IsEqualIID(riid, &IID_IUnknown) ||
64 IsEqualIID(riid, &IID_IFileSystemBindData))
66 *ppV = &This->IFileSystemBindData_iface;
71 IFileSystemBindData_AddRef(iface);
72 TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
75 TRACE("-- Interface: E_NOINTERFACE\n");
79 static ULONG WINAPI FileSystemBindData_AddRef(IFileSystemBindData *iface)
81 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
82 ULONG ref = InterlockedIncrement(&This->ref);
83 TRACE("(%p)->(%u)\n", This, ref);
87 static ULONG WINAPI FileSystemBindData_Release(IFileSystemBindData *iface)
89 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
90 ULONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p)->(%u)\n", This, ref);
95 HeapFree(GetProcessHeap(), 0, This);
100 static HRESULT WINAPI FileSystemBindData_GetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
102 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
104 TRACE("(%p)->(%p)\n", This, pfd);
109 *pfd = This->findFile;
113 static HRESULT WINAPI FileSystemBindData_SetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
115 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
117 TRACE("(%p)->(%p)\n", This, pfd);
120 This->findFile = *pfd;
122 memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
126 static const IFileSystemBindDataVtbl FileSystemBindDataVtbl = {
127 FileSystemBindData_QueryInterface,
128 FileSystemBindData_AddRef,
129 FileSystemBindData_Release,
130 FileSystemBindData_SetFindData,
131 FileSystemBindData_GetFindData,
134 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *find_data, LPBC *ppV)
136 FileSystemBindData *This;
139 TRACE("(%p %p)\n", find_data, ppV);
146 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
147 if (!This) return E_OUTOFMEMORY;
149 This->IFileSystemBindData_iface.lpVtbl = &FileSystemBindDataVtbl;
151 IFileSystemBindData_SetFindData(&This->IFileSystemBindData_iface, find_data);
153 ret = CreateBindCtx(0, ppV);
156 static const WCHAR nameW[] = {
157 'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d',' ','D','a','t','a',0};
160 bindOpts.cbStruct = sizeof(BIND_OPTS);
161 bindOpts.grfFlags = 0;
162 bindOpts.grfMode = STGM_CREATE;
163 bindOpts.dwTickCountDeadline = 0;
164 IBindCtx_SetBindOptions(*ppV, &bindOpts);
165 IBindCtx_RegisterObjectParam(*ppV, (WCHAR*)nameW, (IUnknown*)&This->IFileSystemBindData_iface);
167 IFileSystemBindData_Release(&This->IFileSystemBindData_iface);
170 HeapFree(GetProcessHeap(), 0, This);