ReactOS  0.4.14-dev-599-g2d4d3f5
CFileSysBindData.cpp
Go to the documentation of this file.
1 /*
2  * File System Bind Data object to use as parameter for the bind context to
3  * IShellFolder_ParseDisplayName
4  *
5  * Copyright 2003 Rolf Kalbermatter
6  *
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.
11  *
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.
16  *
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
20  *
21  */
22 
23 #include "precomp.h"
24 
26 
27 /***********************************************************************
28  * IFileSystemBindData implementation
29  */
31  public CComObjectRootEx<CComMultiThreadModelNoCS>,
32  public IFileSystemBindData
33 {
34 private:
36 public:
39 
40  // *** IFileSystemBindData methods ***
43 
46 
48  COM_INTERFACE_ENTRY_IID(IID_IFileSystemBindData, IFileSystemBindData)
50 };
51 
53 {
54  CComPtr<IFileSystemBindData> fileSystemBindData;
55  CComPtr<IBindCtx> bindContext;
56  BIND_OPTS bindOpts;
57  HRESULT hResult;
58 
59  TRACE("%p, %p\n", pfd, ppV);
60 
61  if (ppV == NULL)
62  return E_INVALIDARG;
63 
64  *ppV = NULL;
65 
66  hResult = CFileSysBindData::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IFileSystemBindData, &fileSystemBindData));
67  if (FAILED(hResult))
68  return hResult;
69  hResult = fileSystemBindData->SetFindData(pfd);
70  if (FAILED(hResult))
71  return hResult;
72 
73  hResult = CreateBindCtx(0, &bindContext);
74  if (FAILED(hResult))
75  return hResult;
76  bindOpts.cbStruct = sizeof(BIND_OPTS);
77  bindOpts.grfFlags = 0;
78  bindOpts.grfMode = STGM_CREATE;
79  bindOpts.dwTickCountDeadline = 0;
80  hResult = bindContext->SetBindOptions(&bindOpts);
81  if (FAILED(hResult))
82  return hResult;
83  hResult = bindContext->RegisterObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, fileSystemBindData);
84  if (FAILED(hResult))
85  return hResult;
86 
87  *ppV = bindContext.Detach();
88 
89  return S_OK;
90 }
91 
93 {
96  HRESULT ret;
97 
98  TRACE("%p, %p\n", pbc, pfd);
99 
100  if (!pfd)
101  return E_INVALIDARG;
102 
103  ret = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, &pUnk);
104  if (SUCCEEDED(ret))
105  {
107  if (SUCCEEDED(ret))
108  ret = pfsbd->GetFindData(pfd);
109  }
110  return ret;
111 }
112 
114 {
117  HRESULT ret;
118 
119  TRACE("%p, %p\n", pbc, pfd);
120 
121  ret = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, &pUnk);
122  if (SUCCEEDED(ret))
123  {
125  if (SUCCEEDED(ret))
126  ret = pfsbd->SetFindData(pfd);
127  }
128  return ret;
129 }
130 
132 {
133  memset(&findFile, 0, sizeof(WIN32_FIND_DATAW));
134 }
135 
137 {
138  TRACE(" destroying ISFBindPidl(%p)\n", this);
139 }
140 
142 {
143  TRACE("(%p), %p\n", this, pfd);
144 
145  if (!pfd)
146  return E_INVALIDARG;
147 
148  memcpy(pfd, &findFile, sizeof(WIN32_FIND_DATAW));
149  return S_OK;
150 }
151 
153 {
154  TRACE("(%p), %p\n", this, pfd);
155 
156  if (pfd)
157  memcpy(&findFile, pfd, sizeof(WIN32_FIND_DATAW));
158  else
159  memset(&findFile, 0, sizeof(WIN32_FIND_DATAW));
160  return S_OK;
161 }
interface IBindCtx * LPBC
Definition: objfwd.h:18
#define STGM_CREATE
Definition: objbase.h:925
HRESULT WINAPI FileSystemBindData_GetFindData(LPBC pbc, WIN32_FIND_DATAW *pfd)
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:611
static LPOLESTR
Definition: stg_prop.c:27
#define IID_PPV_ARG(Itype, ppType)
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
WIN32_FIND_DATAW findFile
virtual HRESULT STDMETHODCALLTYPE SetFindData(const WIN32_FIND_DATAW *pfd)
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:541
HRESULT WINAPI FileSystemBindData_SetFindData(LPBC pbc, const WIN32_FIND_DATAW *pfd)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
LONG HRESULT
Definition: typedefs.h:77
#define WINAPI
Definition: msvc.h:6
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WINE_DEFAULT_DEBUG_CHANNEL(pidl)
virtual HRESULT STDMETHODCALLTYPE GetFindData(WIN32_FIND_DATAW *pfd)
#define S_OK
Definition: intsafe.h:59
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:561
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:639
#define const
Definition: zconf.h:230
#define END_COM_MAP()
Definition: atlcom.h:552
T * Detach()
Definition: atlcomcli.h:156
nsresult QueryInterface(nsIIDRef riid, void **result)
#define memset(x, y, z)
Definition: compat.h:39
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
#define SUCCEEDED(hr)
Definition: intsafe.h:57