4 * Copyright 2008 Johannes Anderwald <johannes.anderwald@reactos.org>
5 * Copyright 2009 Andrew Hill
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
24 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
27 This folder should not exist. It is just a file system folder... The \windows\fonts
28 directory contains a hidden desktop.ini with a UIHandler entry that specifies a class
29 that lives in fontext.dll. The UI handler creates a custom view for the folder, which
30 is what we normally see. However, the folder is a perfectly normal CFSFolder.
33 /***********************************************************************
34 * IShellFolder implementation
37 CFontsFolder::CFontsFolder()
46 CFontsFolder::~CFontsFolder()
48 TRACE("-- destroying IShellFolder(%p)\n", this);
52 HRESULT WINAPI
CFontsFolder::FinalConstruct()
55 CComPtr
<IPersistFolder3
> ppf3
;
56 hr
= SHCoCreateInstance(NULL
, &CLSID_ShellFSFolder
, NULL
, IID_PPV_ARG(IShellFolder
, &m_pisfInner
));
60 hr
= m_pisfInner
->QueryInterface(IID_PPV_ARG(IShellFolder2
, &m_pisf2Inner
));
64 hr
= m_pisfInner
->QueryInterface(IID_PPV_ARG(IPersistFolder3
, &ppf3
));
68 PERSIST_FOLDER_TARGET_INFO info
;
69 ZeroMemory(&info
, sizeof(PERSIST_FOLDER_TARGET_INFO
));
70 info
.csidl
= CSIDL_FONTS
;
71 hr
= ppf3
->InitializeEx(NULL
, _ILCreateFont(), &info
);
77 HRESULT WINAPI
CFontsFolder::ParseDisplayName(HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
78 ULONG
*pchEaten
, PIDLIST_RELATIVE
*ppidl
, ULONG
*pdwAttributes
)
80 return m_pisfInner
->ParseDisplayName(hwndOwner
, pbc
, lpszDisplayName
, pchEaten
, ppidl
, pdwAttributes
);
83 HRESULT WINAPI
CFontsFolder::EnumObjects(HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
*ppEnumIDList
)
85 return m_pisfInner
->EnumObjects(hwndOwner
, dwFlags
, ppEnumIDList
);
88 HRESULT WINAPI
CFontsFolder::BindToObject(PCUIDLIST_RELATIVE pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
90 return m_pisfInner
->BindToObject(pidl
, pbcReserved
, riid
, ppvOut
);
93 HRESULT WINAPI
CFontsFolder::BindToStorage(PCUIDLIST_RELATIVE pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
95 return m_pisfInner
->BindToStorage(pidl
, pbcReserved
, riid
, ppvOut
);
98 HRESULT WINAPI
CFontsFolder::CompareIDs(LPARAM lParam
, PCUIDLIST_RELATIVE pidl1
, PCUIDLIST_RELATIVE pidl2
)
100 return m_pisfInner
->CompareIDs(lParam
, pidl1
, pidl2
);
103 HRESULT WINAPI
CFontsFolder::CreateViewObject(HWND hwndOwner
, REFIID riid
, LPVOID
*ppvOut
)
105 return m_pisfInner
->CreateViewObject(hwndOwner
, riid
, ppvOut
);
108 HRESULT WINAPI
CFontsFolder::GetAttributesOf(UINT cidl
, PCUITEMID_CHILD_ARRAY apidl
, DWORD
*rgfInOut
)
110 return m_pisfInner
->GetAttributesOf(cidl
, apidl
, rgfInOut
);
113 HRESULT WINAPI
CFontsFolder::GetUIObjectOf(HWND hwndOwner
, UINT cidl
, PCUITEMID_CHILD_ARRAY apidl
,
114 REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
116 return m_pisfInner
->GetUIObjectOf(hwndOwner
, cidl
, apidl
, riid
, prgfInOut
, ppvOut
);
119 HRESULT WINAPI
CFontsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl
, DWORD dwFlags
, LPSTRRET strRet
)
121 if (!_ILIsSpecialFolder(pidl
))
122 return m_pisfInner
->GetDisplayNameOf(pidl
, dwFlags
, strRet
);
124 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl
, dwFlags
, strRet
);
132 WCHAR wszPath
[MAX_PATH
];
134 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
135 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
137 if (!SHGetSpecialFolderPathW(NULL
, wszPath
, CSIDL_FONTS
, FALSE
))
140 else if (!HCR_GetClassNameW(CLSID_FontsFolderShortcut
, wszPath
, MAX_PATH
))
143 strRet
->pOleStr
= (LPWSTR
)CoTaskMemAlloc((wcslen(wszPath
) + 1) * sizeof(WCHAR
));
144 if (!strRet
->pOleStr
)
145 return E_OUTOFMEMORY
;
147 wcscpy(strRet
->pOleStr
, wszPath
);
148 strRet
->uType
= STRRET_WSTR
;
156 HRESULT WINAPI
CFontsFolder::SetNameOf(HWND hwndOwner
, PCUITEMID_CHILD pidl
, /* simple pidl */
157 LPCOLESTR lpName
, DWORD dwFlags
, PITEMID_CHILD
*pPidlOut
)
159 return m_pisfInner
->SetNameOf(hwndOwner
, pidl
, lpName
, dwFlags
, pPidlOut
);
162 HRESULT WINAPI
CFontsFolder::GetDefaultSearchGUID(GUID
*pguid
)
164 return m_pisf2Inner
->GetDefaultSearchGUID(pguid
);
167 HRESULT WINAPI
CFontsFolder::EnumSearches(IEnumExtraSearch
** ppenum
)
169 return m_pisf2Inner
->EnumSearches(ppenum
);
172 HRESULT WINAPI
CFontsFolder::GetDefaultColumn(DWORD dwRes
, ULONG
*pSort
, ULONG
*pDisplay
)
174 return m_pisf2Inner
->GetDefaultColumn(dwRes
, pSort
, pDisplay
);
177 HRESULT WINAPI
CFontsFolder::GetDefaultColumnState(UINT iColumn
, DWORD
*pcsFlags
)
179 return m_pisf2Inner
->GetDefaultColumnState(iColumn
, pcsFlags
);
182 HRESULT WINAPI
CFontsFolder::GetDetailsEx(PCUITEMID_CHILD pidl
, const SHCOLUMNID
*pscid
, VARIANT
*pv
)
184 return m_pisf2Inner
->GetDetailsEx(pidl
, pscid
, pv
);
187 HRESULT WINAPI
CFontsFolder::GetDetailsOf(PCUITEMID_CHILD pidl
, UINT iColumn
, SHELLDETAILS
*psd
)
189 return m_pisf2Inner
->GetDetailsOf(pidl
, iColumn
, psd
);
192 HRESULT WINAPI
CFontsFolder::MapColumnToSCID(UINT column
, SHCOLUMNID
*pscid
)
194 return m_pisf2Inner
->MapColumnToSCID(column
, pscid
);
197 /************************************************************************
198 * CFontsFolder::GetClassID
200 HRESULT WINAPI
CFontsFolder::GetClassID(CLSID
*lpClassId
)
202 TRACE ("(%p)\n", this);
207 *lpClassId
= CLSID_FontsFolderShortcut
;
212 /************************************************************************
213 * CFontsFolder::Initialize
215 * NOTES: it makes no sense to change the pidl
217 HRESULT WINAPI
CFontsFolder::Initialize(LPCITEMIDLIST pidl
)
219 TRACE ("(%p)->(%p)\n", this, pidl
);
224 /**************************************************************************
225 * CFontsFolder::GetCurFolder
227 HRESULT WINAPI
CFontsFolder::GetCurFolder(LPITEMIDLIST
*pidl
)
229 TRACE ("(%p)->(%p)\n", this, pidl
);
234 *pidl
= ILClone(pidlRoot
);