2 * Copyright 2003, 2004, 2005 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 // Martin Fuchs, 23.07.2003
29 /// shell file/directory entry
30 struct ShellEntry
: public Entry
32 ShellEntry(Entry
* parent
, LPITEMIDLIST shell_path
) : Entry(parent
, ET_SHELL
), _pidl(shell_path
) {}
33 ShellEntry(Entry
* parent
, const ShellPath
& shell_path
) : Entry(parent
, ET_SHELL
), _pidl(shell_path
) {}
35 virtual bool get_path(PTSTR path
, size_t path_count
) const;
36 virtual ShellPath
create_absolute_pidl() const;
37 virtual HRESULT
GetUIObjectOf(HWND hWnd
, REFIID riid
, LPVOID
* ppvOut
);
38 virtual BOOL
launch_entry(HWND hwnd
, UINT nCmdShow
=SW_SHOWNORMAL
);
39 virtual HRESULT
do_context_menu(HWND hwnd
, const POINT
& pptScreen
, CtxMenuInterfaces
& cm_ifs
);
40 virtual ShellFolder
get_shell_folder() const;
42 IShellFolder
* get_parent_folder() const;
44 ShellPath _pidl
; // parent relative PIDL
47 ShellEntry(LPITEMIDLIST shell_path
) : Entry(ET_SHELL
), _pidl(shell_path
) {}
48 ShellEntry(const ShellPath
& shell_path
) : Entry(ET_SHELL
), _pidl(shell_path
) {}
52 /// shell folder entry
53 struct ShellDirectory
: public ShellEntry
, public Directory
55 ShellDirectory(ShellFolder
& root_folder
, const ShellPath
& shell_path
, HWND hwnd
)
56 : ShellEntry(shell_path
),
57 _folder(root_folder
, shell_path
),
60 CONTEXT("ShellDirectory::ShellDirectory()");
62 lstrcpy(_data
.cFileName
, root_folder
.get_name(shell_path
, SHGDN_FORADDRESSBAR
));
63 _data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
64 _shell_attribs
= SFGAO_FOLDER
;
66 ShellFolder
subfolder(root_folder
, shell_path
);
67 IShellFolder
* pFolder
= subfolder
;
72 explicit ShellDirectory(ShellDirectory
* parent
, LPITEMIDLIST shell_path
, HWND hwnd
)
73 : ShellEntry(parent
, shell_path
),
74 _folder(parent
->_folder
, shell_path
),
77 /* not neccessary - the caller will fill the info
78 lstrcpy(_data.cFileName, _folder.get_name(shell_path));
79 _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
80 _shell_attribs = SFGAO_FOLDER; */
86 ShellDirectory(const ShellDirectory
& other
)
89 _folder(other
._folder
),
92 IShellFolder
* pFolder
= (IShellFolder
*)_path
;
98 IShellFolder
* pFolder
= (IShellFolder
*)_path
;
103 virtual void read_directory(int scan_flags
=0);
104 virtual const void* get_next_path_component(const void*) const;
105 virtual Entry
* find_entry(const void*);
107 virtual bool get_path(PTSTR path
, size_t path_count
) const;
108 virtual ShellFolder
get_shell_folder() const;
110 int extract_icons(ICONCACHE_FLAGS flags
);
116 bool fill_w32fdata_shell(LPCITEMIDLIST pidl
, SFGAOF attribs
, WIN32_FIND_DATA
*, BY_HANDLE_FILE_INFORMATION
*, bool do_access
=true);
120 inline IShellFolder
* ShellEntry::get_parent_folder() const
123 return static_cast<ShellDirectory
*>(_up
)->_folder
;
125 return GetDesktopFolder();