include: Use proper dllimports for propsys functions.
[wine.git] / dlls / shell32 / shlfsbind.c
blob75441d01bcee836883c04f781218af291085fe6f
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
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "shlobj.h"
31 #include "shell32_main.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(pidl);
37 /***********************************************************************
38 * IFileSystemBindData implementation
40 typedef struct
42 IFileSystemBindData IFileSystemBindData_iface;
43 LONG ref;
44 WIN32_FIND_DATAW findFile;
45 } FileSystemBindData;
47 static inline FileSystemBindData *impl_from_IFileSystemBindData(IFileSystemBindData *iface)
49 return CONTAINING_RECORD(iface, FileSystemBindData, IFileSystemBindData_iface);
52 static HRESULT WINAPI FileSystemBindData_QueryInterface(
53 IFileSystemBindData *iface, REFIID riid, LPVOID *ppV)
55 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
57 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppV);
59 *ppV = NULL;
61 if (IsEqualIID(riid, &IID_IUnknown) ||
62 IsEqualIID(riid, &IID_IFileSystemBindData))
64 *ppV = &This->IFileSystemBindData_iface;
67 if (*ppV)
69 IFileSystemBindData_AddRef(iface);
70 TRACE("-- Interface: (%p)->(%p)\n", ppV, *ppV);
71 return S_OK;
73 TRACE("-- Interface: E_NOINTERFACE\n");
74 return E_NOINTERFACE;
77 static ULONG WINAPI FileSystemBindData_AddRef(IFileSystemBindData *iface)
79 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
80 ULONG ref = InterlockedIncrement(&This->ref);
81 TRACE("(%p)->(%lu)\n", This, ref);
82 return ref;
85 static ULONG WINAPI FileSystemBindData_Release(IFileSystemBindData *iface)
87 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
88 ULONG ref = InterlockedDecrement(&This->ref);
90 TRACE("(%p)->(%lu)\n", This, ref);
92 if (!ref)
93 free(This);
95 return ref;
98 static HRESULT WINAPI FileSystemBindData_GetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd)
100 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
102 TRACE("(%p)->(%p)\n", This, pfd);
104 if (!pfd)
105 return E_INVALIDARG;
107 *pfd = This->findFile;
108 return S_OK;
111 static HRESULT WINAPI FileSystemBindData_SetFindData(IFileSystemBindData *iface, const WIN32_FIND_DATAW *pfd)
113 FileSystemBindData *This = impl_from_IFileSystemBindData(iface);
115 TRACE("(%p)->(%p)\n", This, pfd);
117 if (pfd)
118 This->findFile = *pfd;
119 else
120 memset(&This->findFile, 0, sizeof(WIN32_FIND_DATAW));
121 return S_OK;
124 static const IFileSystemBindDataVtbl FileSystemBindDataVtbl = {
125 FileSystemBindData_QueryInterface,
126 FileSystemBindData_AddRef,
127 FileSystemBindData_Release,
128 FileSystemBindData_SetFindData,
129 FileSystemBindData_GetFindData,
132 HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *find_data, LPBC *ppV)
134 FileSystemBindData *This;
135 HRESULT ret;
137 TRACE("(%p %p)\n", find_data, ppV);
139 if (!ppV)
140 return E_INVALIDARG;
142 *ppV = NULL;
144 This = malloc(sizeof(*This));
145 if (!This) return E_OUTOFMEMORY;
147 This->IFileSystemBindData_iface.lpVtbl = &FileSystemBindDataVtbl;
148 This->ref = 1;
149 IFileSystemBindData_SetFindData(&This->IFileSystemBindData_iface, find_data);
151 ret = CreateBindCtx(0, ppV);
152 if (SUCCEEDED(ret))
154 BIND_OPTS bindOpts;
156 bindOpts.cbStruct = sizeof(BIND_OPTS);
157 bindOpts.grfFlags = 0;
158 bindOpts.grfMode = STGM_CREATE;
159 bindOpts.dwTickCountDeadline = 0;
160 IBindCtx_SetBindOptions(*ppV, &bindOpts);
161 IBindCtx_RegisterObjectParam(*ppV, (WCHAR*)L"File System Bind Data", (IUnknown*)&This->IFileSystemBindData_iface);
163 IFileSystemBindData_Release(&This->IFileSystemBindData_iface);
165 else
166 free(This);
167 return ret;