d3dx9/tests: Add basic tests for ID3DXRenderToEnvMap.
[wine/multimedia.git] / dlls / shell32 / shlfsbind.c
blob53a1d3b0aa7bfa0620ecc8371b85c7134d3b6b54
1 /*
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
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
27 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "shlobj.h"
33 #include "shell32_main.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(pidl);
39 /***********************************************************************
40 * IFileSystemBindData implementation
42 typedef struct
44 IFileSystemBindData IFileSystemBindData_iface;
45 LONG ref;
46 WIN32_FIND_DATAW findFile;
47 } FileSystemBindData;
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);
61 *ppV = NULL;
63 if (IsEqualIID(riid, &IID_IUnknown) ||
64 IsEqualIID(riid, &IID_IFileSystemBindData))
66 *ppV = &This->IFileSystemBindData_iface;
69 if (*ppV)
71 IFileSystemBindData_AddRef(iface);
72 TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
73 return S_OK;
75 TRACE("-- Interface: E_NOINTERFACE\n");
76 return E_NOINTERFACE;
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);
84 return 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);
94 if (!ref)
95 HeapFree(GetProcessHeap(), 0, This);
97 return ref;
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);
106 if (!pfd)
107 return E_INVALIDARG;
109 *pfd = This->findFile;
110 return S_OK;
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);
119 if (pfd)
120 This->findFile = *pfd;
121 else
122 memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
123 return S_OK;
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;
137 HRESULT ret;
139 TRACE("(%p %p)\n", find_data, ppV);
141 if (!ppV)
142 return E_INVALIDARG;
144 *ppV = NULL;
146 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
147 if (!This) return E_OUTOFMEMORY;
149 This->IFileSystemBindData_iface.lpVtbl = &FileSystemBindDataVtbl;
150 This->ref = 1;
151 IFileSystemBindData_SetFindData(&This->IFileSystemBindData_iface, find_data);
153 ret = CreateBindCtx(0, ppV);
154 if (SUCCEEDED(ret))
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};
158 BIND_OPTS bindOpts;
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);
169 else
170 HeapFree(GetProcessHeap(), 0, This);
171 return ret;