OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
shellitm.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definitions of Win95 Shell Clases:
7/// TShellItem, TShellItemIterator, TPidl, TShellMalloc
8///
9/// Also the following lightweight "wrapper" classes are defined:
10/// TExtractIcon, TContextMenu, TDataObject, TDropTarget
11///
12/// These are wrapper classes for the Win95 deskop.
13//----------------------------------------------------------------------------
14
15#if !defined(OWL_SHELLITM_H)
16#define OWL_SHELLITM_H
17
18#include <owl/defs.h>
19#if defined(BI_HAS_PRAGMA_ONCE)
20# pragma once
21#endif
22
23
24#include <owl/except.h>
25#include <owl/pointer.h>
26#include <owl/string.h>
27
28#if defined(BI_COMP_MSC)
29#pragma warning(push)
30#pragma warning(disable:4091) // warning C4091: 'typedef ': ignored on left of '' when no variable is declared
31#endif
32
33#include <shlobj.h>
34
35#if defined(BI_COMP_MSC)
36#pragma warning(pop)
37#endif
38
39namespace owl {
40
41#include <owl/preclass.h>
42
43/// \addtogroup winsys
44/// @{
45
46//
47/// \class TShell
48// ~~~~~ ~~~~~~
49/// delay loading SHELL32.DLL/SHELL.DLL
51 public:
52 static void DragAcceptFiles(HWND,BOOL);
53 static void DragFinish(HDROP);
54 static UINT DragQueryFile(HDROP,UINT,LPTSTR,UINT);
55 static BOOL DragQueryPoint(HDROP,LPPOINT);
56 static HICON ExtractIcon(HINSTANCE,LPCTSTR,UINT);
57 static HINSTANCE ShellExecute(HWND,LPCTSTR,LPCTSTR,LPCTSTR,LPCTSTR,INT);
58
59 static void SHAddToRecentDocs(UINT, LPCVOID);
60 static LPITEMIDLIST SHBrowseForFolder(LPBROWSEINFO);
61 static void SHChangeNotify(LONG,UINT,LPCVOID,LPCVOID);
62 static DWORD SHGetFileInfo(LPCTSTR,DWORD,SHFILEINFO *,UINT,UINT);
63 static int SHFileOperation(LPSHFILEOPSTRUCT);
64 static HRESULT SHGetDesktopFolder(LPSHELLFOLDER*);
65 static HRESULT SHGetMalloc(LPMALLOC*);
66 static BOOL SHGetPathFromIDList(LPCITEMIDLIST,LPTSTR);
67 static HRESULT SHGetSpecialFolderLocation(HWND,int,LPITEMIDLIST*);
68 static BOOL Shell_NotifyIcon(DWORD,PNOTIFYICONDATA);
69
70 static TModule& GetModule();
71};
72
73//
74/// \class TShellMalloc
75// ~~~~~ ~~~~~~~~~~~~
76/// Wraps the shell's IMalloc interface.
77/// Default constructor obtains shell's IMalloc interface.
78/// TComRef<IMalloc> and copy constructors supplied.
79/// TComRef<IMalloc> and TShellMalloc assignment operators also supplied.
80//
81//
90
91//
92/// \class TExtractIcon
93// ~~~~~ ~~~~~~~~~~~~
94/// Wraps the IExtractIcon interface (currently lightweight).
95/// A TExtractIcon is returned by TShellItem::GetExtractIcon.
96/// Default, TComRef<IExtractIcon> and copy constructors supplied.
97/// TComRef<IExtractIcon> and TExtractIcon assignment opreators also supplied.
98//
107
108//
109/// \class TContextMenu
110// ~~~~~ ~~~~~~~~~~~~
111/// Wraps the IContextMenu interface (currently lightweight).
112/// A TContextMenu is returned by TShellItem::GetContextMenu.
113/// Default, TComRef<IContextMenu> and copy constructors supplied.
114/// TComRef<IContextMenu> and TContextMenu assignment opreators also supplied.
115//
124
125//
126/// \class TDataObject
127// ~~~~~ ~~~~~~~~~~~
128/// Wraps the IDataObject interface (currently lightweight).
129/// A TDataObject is returned by TShellItem::GetDataObject.
130/// Default, TComRef<IDataObject> and copy constructors supplied.
131/// TComRef<IDataObject> and TDataObject assignment opreators also supplied.
132//
141
142//
143/// \class TDropTarget
144// ~~~~~ ~~~~~~~~~~~
145/// Wraps the IDropTarget interface (currently lightweight).
146/// A TDropTarget is returned by TShellItem::GetDropTarget.
147/// Default, TComRef<IDropTarget> and copy constructors supplied.
148/// TComRef<IDropTarget> and TDropTarget assignment opreators also supplied.
149//
158
159//
160/// \class TPidl
161// ~~~~~ ~~~~~
162/// TPidl is an item identifier list class (ITEMIDLIST). Its constructor takes an
163/// LPITEMIDLIST (a.k.a., pidl). The copy constructor and assignement operators
164/// supplied function to manipulate the ITEMIDLIST, get the size, get the number of
165/// items in the list, etc, supplied. Normally, the programmer will not have to be
166/// concerned with ITEMIDLISTs nor with the TPidl class. The TShellItem class hides
167/// all this.
168//
170 public:
171 static LPITEMIDLIST Next(LPITEMIDLIST pidl);
172
173 // TPidl constructors and destructor
174 //
176 TPidl(const TPidl& source);
177 virtual ~TPidl();
178
179 // Assignment operators
180 //
181 TPidl& operator = (const TPidl& source);
183
184 // Test to see if valid pidl
185 bool operator !() const;
186
187 /// Use TPidl in place of pidl
188 //
189 operator LPCITEMIDLIST () const;
190 operator LPITEMIDLIST ();
191
192 /// Use TPidl in place of pointer to a pidl
193 //
194 operator LPCITEMIDLIST* () const;
195 operator LPITEMIDLIST* ();
196
197 /// Get size (in bytes) of a pidl
198 //
199 ulong GetSize() const;
200
201 /// Get number of item ids in the TPidl (the TPidl can be a list of ids)
202 //
203 long GetItemCount() const;
204
205 /// Get the last item id in the TPidl
206 //
207 TPidl GetLastItem() const;
208
209 /// Return a TPidl with the last item id stripped off of it
210 //
211 TPidl StripLastItem() const;
212
213 /// Copy a pidl
214 //
215 LPITEMIDLIST CopyPidl() const;
216
217 protected:
218 /// Free a pidl with the shell's allocator
219 //
220 void FreePidl();
221
223
224 /// A PIDL
225 //
226 LPITEMIDLIST Pidl;
227};
228
229//
230/// \class TShellItem
231// ~~~~~ ~~~~~~~~~~
232/// An item in the shell's name space. All items in the shell's
233/// namespace can be identified by a fully qualified pidl. Another
234/// way to uniquely identify an item is via it's parent and an item id
235/// (i.e., a single item rather than a list). A TShellItem contains a
236/// parent (TComRef<IShellFolder> ParentFolder) and the item id (TPidl pidl)
237//
238class _OWLCLASS TShellItem: public TComRef<IShellFolder> {
239 public:
240 /// Used by TShelItem::GetDisplayName() and TShellItem::Rename()
241 /// See MS doc for SHGNO for more information, Programmer's
242 /// Guide to MS Windows 95, MS Press, p. 218.
243 //
245 Normal = SHGDN_NORMAL, ///< File object displayed by itself.
246 InFolder = SHGDN_INFOLDER, ///< File object displayed within a folder.
247 ForParsing = SHGDN_FORPARSING ///< File object suitable for parsing.
248 };
249 /// Used by TShellItem::GetIcon
250 /// See MS doc for SHGetFileInfo for more information, Programmer's
251 /// Guide to MS Windows 95, MS Press, pp. 205-207.
252 enum TIconSize { Large = SHGFI_LARGEICON, ///< Retrieves the shell item's large icon
253 Small = SHGFI_SMALLICON, ///< Retrieves the shell item's small icon
254 Shell = SHGFI_SHELLICONSIZE ///< Retrieves the shell-sized icon (if unavailable, the normal icon
255 ///< is sized according to the system metric values)
256 };
257
258 /// Used by TShellItem::GetIcon
259 /// See MS doc for SHGetFileInfo for more information, Programmer's
260 /// Guide to MS Windows 95, MS Press, pp. 205-207.
261 //
263 Link = SHGFI_LINKOVERLAY, ///< Adds the link overlay to the shell item's icon
264 Open = SHGFI_OPENICON, ///< Retrieves the shell item's open icon
265 Selected = SHGFI_SELECTED ///< Blends the shell item's icon with the system highlight color
266 };
267
268 /// Used by TShellItem::TShellItem(const TSpecialFolderKind kind,
269 /// HWND windowOwner = 0)
270 /// See MS doc for SHGetSpecialFolderLocation for more information,
271 /// Programmer's Guide to MS Windows 95, MS Press, pp. 209-210.
272 //
274 RecycleBin = CSIDL_BITBUCKET, ///< Directory containing file objects in the user's recycle bin
275 ControlPanel = CSIDL_CONTROLS, ///< Virtual folder containing icons for the Control Panel
276 Desktop = CSIDL_DESKTOP, ///< Virtual folder at the root of the namespace
277 DesktopFileDir = CSIDL_DESKTOPDIRECTORY, ///< Directory used to physically store file objects on the desktop
278 MyComputer = CSIDL_DRIVES, ///< Virtual folder containing everything on the local computer
279 Fonts = CSIDL_FONTS, ///< Virtual folder containing fonts
280 NetworkNeighborhoodFileDir = CSIDL_NETHOOD, ///< Directory containing objects that appeat in the Network Neighborhood
281 NetworkNeighborhood = CSIDL_NETWORK, ///< Virtual folder representing the top level of the network hierarchy
282 CommonDocuments = CSIDL_PERSONAL, ///< Directory that serves as a repository for common documents
283 Printers = CSIDL_PRINTERS, ///< Virtual folder containing installed printers
284 Programs = CSIDL_PROGRAMS, ///< Directory containing the user's program groups
285 RecentDocuments = CSIDL_RECENT, ///< Directory containing the user's most recently used documents
286 SendTo = CSIDL_SENDTO, ///< Directory containing Send To menu items
287 StartMenu = CSIDL_STARTMENU, ///< Directory containing Start menu items
288 Startup = CSIDL_STARTUP, ///< Directory that corresponds to the user's Startup program group
289 CommonTemplates = CSIDL_TEMPLATES, ///< Directory that serves as a repository for document templates
290 Favorites = CSIDL_FAVORITES ///<
291 };
292
293 /// Used by TShellItem::GetAttributes
294 /// See MS doc for IShellFolder::GetAttributesOf for more information,
295 /// Programmer's Guide to MS Windows 95, MS Press, pp. 194-196.
296 //
298 // Capabilities
299 //
300 atCapabilityMask = SFGAO_CAPABILITYMASK, ///< Mask for the capability flags
301 atCanBeCopied = SFGAO_CANCOPY, ///< The shell item can be copied
302 atCanBeDeleted = SFGAO_CANDELETE, ///< The shell item can be deleted
303 atCanCreateShortcut = SFGAO_CANLINK, ///< Shortcuts can be created for the shell item
304 atCanBeMoved = SFGAO_CANMOVE, ///< The shell item can be moved
305 atCanBeRenamed = SFGAO_CANRENAME, ///< The shell item can be renamed
306 atIsADropTarget = SFGAO_DROPTARGET, ///< The shell item is a drop target
307 atHasAPropertySheet = SFGAO_HASPROPSHEET, ///< The shell item has a property sheet
308
309 // Display Attributes
310 //
311 atDisplayAttributeMask = SFGAO_DISPLAYATTRMASK, ///< Mask for the display attributes
312 atDisplayGhosted = SFGAO_GHOSTED, ///< The shell item should be displayed using a ghosted icon
313 atIsShortcut = SFGAO_LINK, ///< The shell item is a shortcut
314 atIsReadOnly = SFGAO_READONLY, ///< The shell item is readonly
315 atIsShared = SFGAO_SHARE, ///< The shell item is shared
316
317 // Contents
318 //
319 atContentsMask = SFGAO_CONTENTSMASK, ///< Mask for the contents attributes
320 atContainsSubFolder = SFGAO_HASSUBFOLDER, ///< The shell item has subfolders
321
322 // Miscellaneous
323 //
324 atContainsFileSystemFolder = SFGAO_FILESYSANCESTOR, ///< The shell item contains one or more system folders
325 atIsPartOfFileSystem = SFGAO_FILESYSTEM, ///< The shell item is part of the file system
326 atIsFolder = SFGAO_FOLDER, ///< The shell item is a folder
327 atCanBeRemoved = SFGAO_REMOVABLE ///< The shell item is on removable media
328 };
329
330 /// Used by TShellItem::Rename,Copy,Move,Delete
331 /// See MS doc for SHFILEOPSTRUCT for more information, Programmer's
332 /// Guide to MS Windows 95, MS Press, pp. 214-215.
333 //
335 AllowUndo = FOF_ALLOWUNDO, ///< Preserves undo information (if possible)
336 NoConfirmation = FOF_NOCONFIRMATION, ///< Responds with "yes to all" for any dialog
337 NoConfirmMkDir = FOF_NOCONFIRMMKDIR, ///< No confirmation on the creation of a new directory
338 RenameOnCollision = FOF_RENAMEONCOLLISION, ///< Renames the file being operated on if a file of the same name already exists (i.e., Copy #1 of ...)
339 Silent = FOF_SILENT, ///< No progess dialog box is displayed
340 SimpleProgress = FOF_SIMPLEPROGRESS ///< A simple progress dialog box is diaplayed (no file names)
341 };
342
343 /// Used by TShellItem::BrowseForFolder
344 /// See MS doc for BROWSEINFO for more information, Programmer's
345 /// Guide to MS Windows 95, MS Press, pp. 211-212.
346 //
348 OnlyComputers, ///< Returns only computers
349 OnlyPrinters, ///< Returns only printers
350 NoNetorkFoldersBelowDomain, ///< Does not return network folders below the domain
351 OnlyFSAncestors, ///< Returns only file system ancestors
352 OnlyFSDirs ///< Returns only file system directories
353 };
354
355 /// Returned by TShellItem::GetExeType
356 /// See MS doc for SHGetFileInfo for more information, Programmer's
357 /// Guide to MS Windows 95, MS Press, pp. 205-207.
358 //
359 enum TExeKind {
360 NonExecutable, ///< Nonexecutable file or an error condition
361 WindowsNE, ///< Windows-based application
362 WindowsPE, ///< Windows level (3.0, 3.5, or 4.0)
363 MSDOS, ///< MS-DOS .EXE, .COM, or .BAT file
364 Win32Console ///< Win32-based console application
365 };
366
367 /// TCreateStruct contains information to construct a TShellItem
368 /// Typically a TCreateStruct is returned (for example by GetParentFolder)
369 /// and this TCreateStruct is used to construct a TshellItem
370 /// Passed in as arguments to:
371 /// - TShellItem::TShellItem(const TCreateStruct& cs)
372 /// - TShellItem::operator =(const TCreateStruct& cs)
373 /// Returned as an out argument by:
374 /// - TShellItem::BrowseForFolder
375 /// - TShellItem::ParseDisplayName
376 /// Returned by:
377 /// - TShellItem::GetParentFolder
378 /// - TShellItemIterator::operator ++ ();
379 /// - TShellItemIterator::operator ++ (int);
380 /// - TShellItemIterator::operator -- ();
381 /// - TShellItemIterator::operator -- (int);
382 /// - TShellItemIterator::operator [] (const long index);
383 /// - TShellItemIterator::Current();
384 //
393
394 // Constructors for TShellItem
395 //
396 TShellItem(const tchar* path, bool throwOnInvalidPath = true, HWND windowOwner = 0);
398 TShellItem(const TCreateStruct& cs); // used with TShellItemIterator
402
403 // Assignment operators
404 //
407
408 /// Determine if TShellItem reprsents a valid item
409 //
410 bool Valid() const;
411
412 /// Allow TShellItems to be used in place of pidls
413 operator LPCITEMIDLIST() const; // 05/26/98 Yura Bidus
414
415 // Get TExtractIcon, TContextMenu, TDataObject, TDropTarget for a TShellItem
416 TExtractIcon GetExtractIcon(HWND windowOwner = 0);
417 TContextMenu GetContextMenu(HWND windowOwner = 0);
418 TDataObject GetDataObject(HWND windowOwner = 0);
419 TDropTarget GetDropTarget(HWND windowOwner = 0);
420 HICON GetIcon(TIconSize size = Shell, uint kind = 0);
421
422 /// Get Attributes of a TShellItem
423 /// GetAttributes - Get Capabilities, Display, Contents, & Misc. Attributes with one call
424 //
425 ulong GetAttributes(const ulong reqAttrib, const bool validateCachedInfo = false) const;
426
427 // Attributes - Capabilties
428 //
429 bool CanBeCopied(const bool validateCachedInfo = false) const;
430 bool CanBeDeleted(const bool validateCachedInfo = false) const;
431 bool CanCreateShortcut(const bool validateCachedInfo = false) const;
432 bool CanBeMoved(const bool validateCachedInfo = false) const;
433 bool CanBeRenamed(const bool validateCachedInfo = false) const;
434 bool IsADropTarget(const bool validateCachedInfo = false) const;
435 bool HasAPropertySheet(const bool validateCachedInfo = false)const;
436
437 // Attributes - Display
438 //
439 bool DisplayGhosted(const bool validateCachedInfo = false) const;
440 bool IsShortcut(const bool validateCachedInfo = false) const;
441 bool IsReadOnly(const bool validateCachedInfo = false) const;
442 bool IsShared(const bool validateCachedInfo = false) const;
443
444 // Attributes - Contents
445 //
446 bool ContainsSubFolder(const bool validateCachedInfo = false) const;
447
448 // Attributes - Miscellaneous
449 //
450 bool ContainsFileSystemFolder(const bool validateCachedInfo = false) const;
451 bool IsPartOfFileSystem(const bool validateCachedInfo = false) const;
452 bool IsFolder(const bool validateCachedInfo = false) const;
453 bool CanBeRemoved(const bool validateCachedInfo = false) const;
454
455 // Attributes - Additional (Not part of GetAttributes)
456 //
457 bool IsDesktop() const;
458
459 /// Get TPidl (relative to parent)
460 //
461 TPidl GetPidl() const;
462
463 /// Get fully qualified TPidl
464 //
465 TPidl GetFullyQualifiedPidl() const;
466
467 /// Get Parent Folder
468 //
469 TCreateStruct GetParentFolder() const;
470
471 /// Get type of executable file (may return NonExecutable)
472 //
473 TExeKind GetExeType(uint* major = 0, uint* minor = 0) const;
474
475 /// Get type of file (e.g., "Borland C++ Header File", "Notepad File")
476 //
477 TString GetTypeName() const;
478
479 /// Get Displayname (for a TShellItem that's part of the filesystem, this is the filename)
480 //
481 TString GetDisplayName(const TDisplayNameKind kind = Normal) const;
482
483 /// Get path (only call if the TShellItem is part of the file system (IsPartOfFileSystem == true)
484 //
485 TString GetPath() const;
486
487 // File Opertations (Rename, Copy, Move, Delete)
488 //
489 void Rename(const tchar* newName, HWND windowOwner = 0,
490 const TDisplayNameKind kind = Normal);
491 bool Copy(const tchar* dest, const bool destIsFolder = true,
492 const USHORT flags = 0, const tchar* title = 0,
493 HWND windowOwner = 0) const;
494 bool Copy(const TShellItem& dest, const USHORT flags = 0, const tchar* title = 0,
495 HWND windowOwner = 0) const;
496 bool Move(const tchar* destFolder, const USHORT flags = 0,
497 const tchar* title = 0, HWND windowOwner = 0);
498 bool Move(const TShellItem& destFolder, const USHORT flags = 0,
499 const tchar* title = 0, HWND windowOwner = 0);
500 bool Delete(const USHORT flags = 0, const tchar* title = 0,
501 HWND windowOwner = 0);
502
503 /// Add to recent docs (Win95 taskbar:Start:Documents)
504 //
505 void AddToRecentDocs() const;
506
507 /// Get the TShellItem that a shortcut points to
508 //
509 TShellItem ResolveShortcut(HWND windowOwner = 0);
510
511 // Create a shortcut
512 // TODO: Add string-aware overloads.
513 //
514 static HRESULT CreateShortCut(LPCTSTR objPath, LPTSTR pathLink,
515 LPTSTR description);
516 static HRESULT CreateShortCut(LPCITEMIDLIST pidl, LPTSTR pathLink,
517 LPTSTR description);
518 TShellItem CreateShortCut(LPTSTR pathLink, LPTSTR description);
519
520 // Pidl compares (so that they can be ordered)
521 //
522 bool operator==(const TShellItem& rhs) const;
523 bool operator!=(const TShellItem& rhs) const;
524 bool operator<(const TShellItem& rhs) const;
525 bool operator<=(const TShellItem& rhs) const;
526 bool operator>(const TShellItem& rhs) const;
527 bool operator>=(const TShellItem& rhs) const;
528
529 // Folder Only Functions
530 // EnumObjects is called by TShellItemIterator
531 //
532 void EnumObjects(IEnumIDList** iface, HWND windowOwner = 0,
533 const int kind = -1) const;
534 /// Select a Foler under this TShellItem
535 //
536 bool BrowseForFolder(TCreateStruct& cs, HWND windowOwner = 0,
537 const tchar* title = 0, const UINT flags = 0,
538 int* image = 0, const bool includeStatus = false,
539 BFFCALLBACK func = 0, const LPARAM param = 0) const;
540
541 /// Parse a display name into a TShellItem (actually, into a TCreateStruct)
542 //
543 HRESULT ParseDisplayName(TCreateStruct& cs, const tchar* displayName,
544 ulong* eaten = nullptr, HWND windowOwner = nullptr,
545 ulong* attrib = nullptr) const;
546 protected:
547 // CompareIDs is used by the pidl compare functions above
548 //
549 short CompareIDs(const TShellItem& rhs) const;
550 void EnforceValidity() const;
551 void RetrieveIShellFolder() const;
552 bool HaveSameParent(const TShellItem& other) const;
553 bool GetAttribute(const TAttribute at, const bool validateCachedInfo) const;
555 TPidl Pidl;
556 TComRef<IShellFolder> ParentFolder;
557};
558
559//
560/// \class TShellItemIterator
561// ~~~~~ ~~~~~~~~~~~~~~~~~~
562/// TShellItemIterator is an interator for walking through the contents of a folder.
563/// A folder is a TShellItem whose IsFolder or ContainsSubFolder attributes are true.
564//
565class _OWLCLASS TShellItemIterator: public TComRef<IEnumIDList> {
566 public:
567 /// Used by TShellItemIterator::TShellItemIterator(const TShellItem& folder,
568 /// HWND windowOwner = 0, const UINT kind = Folders | NonFolders)
569 /// See MS doc for SHCONTF for more information, Programmer's Guide to
570 /// MS Windows 95, MS Press, p. 213.
572 Folders = SHCONTF_FOLDERS, ///< For shell browser
573 NonFolders = SHCONTF_NONFOLDERS, ///< For default view
574 HiddenAndSystem = SHCONTF_INCLUDEHIDDEN ///< For hidden or system objects
575 };
576
577 // constructor for TShellItemIterator
578 //
580 const int kind = Folders | NonFolders);
582
583 /// Assignment operator
584 //
586
587 /// True if iterator is still valid
588 //
589 bool Valid() const;
590
591 /// Get number of TShellItems in the list
592 //
593 long GetCount() const;
594
595 // Get next item, previous item, item at index, and current item
596 //
601 TShellItem::TCreateStruct operator [] (const long index);
603
604 /// Skip count items
605 //
606 void Skip(const ulong count);
607
608 /// Reset list
609 //
610 void Reset();
611
612 protected:
613 void Next();
614 void EnforceValidInterface() const;
615
617 long Index;
618 TPidl Pidl;
620 operator IEnumIDList**();
621};
622
623//
624/// \class TXShell
625// ~~~~~ ~~~~~~~
626/// Base Shell exception class. Handles all TShellItem and related class exceptions
627//
628class _OWLCLASS TXShell: public TXOwl {
629 public:
630 // Constructor for TXShell
631 //
633
634 // Clone a TXShell
635 //
636 TXShell* Clone();
637
638 // Throw an exception
639 //
640 void Throw();
641
642 // Construct a TXShell exception from scratch, and throw it.
643 //
644 static void Raise(uint resId = IDS_SHELLFAILURE, HANDLE handle = 0);
645
646 // Check an HRESULT and throw a TXShell if not SUCCEEDED(hr)
647 //
648 static void Check(HRESULT hr, uint resId = IDS_SHELLFAILURE, HANDLE handle = 0);
649};
650
651/// @}
652
653#include <owl/posclass.h>
654
655
656//----------------------------------------------------------------------------
657// Inline implementations
658//
659
660/// Default constructor for TShellMalloc. For more info, see MS doc for
661/// SHGetMalloc (Prog. Guide to MS Win95, p. 208)
662//
668
669/// TShellMalloc constructor to construct from TComRef<IMalloc>
670//
675
676/// TShellMalloc copy constructor
677//
682
683/// TShellMalloc assignment operator (from TComRef<IMalloc>)
684//
685inline TShellMalloc&
687{
688 if (&source != this)
690 return *this;
691}
692
693/// TShellMalloc assignment operator (from another TShellMalloc)
694//
695inline TShellMalloc&
697{
698 if (&source != this)
700 return *this;
701}
702
703/// Default constructor for TExtractIcon
704//
709
710/// TExtractIcon constructor to construct from TComRef<IExtractIcon>
711//
716
717/// TExtractIcon copy constructor
718//
723
724/// TExtractIcon assignment operator (from TComRef<IExtractIcon>)
725//
726inline TExtractIcon&
728{
729 if (&source != this)
731 return *this;
732}
733
734/// TExtractIcon assignment operator (from another TExtractIcon)
735//
736inline TExtractIcon&
738{
739 if (&source != this)
741 return *this;
742}
743
744/// Default constructor for TContextMenu
745//
750
751/// TContextMenu constructor to construct from TComRef<IContextMenu>
752//
757
758/// TContextMenu copy constructor
759//
764
765/// TContextMenu assignment operator (from TComRef<IContextMenu>)
766//
767inline TContextMenu&
769{
770 if (&source != this)
772 return *this;
773}
774
775/// TContextMenu assignment operator (from another TContextMenu)
776//
777inline TContextMenu&
779{
780 if (&source != this)
782 return *this;
783}
784
785/// Default constructor for TDataObject
786//
792
793/// TDataObject constructor to construct from TComRef<IDataObject>
794//
799
800/// TDataObject copy constructor
801//
806
807/// TDataObject assignment operator (from TComRef<IDataObject>)
808//
809inline TDataObject&
811{
812 if (&source != this)
814 return *this;
815}
816
817/// TDataObject assignment operator (from another TDataObject)
818//
819inline TDataObject&
821{
822 if (&source != this)
824 return *this;
825}
826
827/// Default constructor for TDropTarget
828//
833
834/// TDropTarget constructor to construct from TComRef<IDropTarget>
835//
840
841/// TDropTarget copy constructor
842//
847
848/// TDropTarget assignment operator (from TComRef<IDropTarget>)
849//
850inline TDropTarget&
852{
853 if (&source != this)
855 return *this;
856}
857
858/// TDropTarget assignment operator (from another TDropTarget)
859//
860inline TDropTarget&
862{
863 if (&source != this)
865 return *this;
866}
867
868/// Check to see if TPidl represents an ITEMIDLIST (return true if it does not)
869//
870inline bool TPidl::operator !() const
871{
872 return Pidl == nullptr;
873}
874
875/// Return next item id (in the list)
876//
877inline LPITEMIDLIST
879{
880 return reinterpret_cast<LPITEMIDLIST>(reinterpret_cast<char*>(pidl) + pidl->mkid.cb);
881}
882
883/// TPidl copy constructor
884//
886 :Pidl(source.CopyPidl())
887{
888}
889
890/// Construct a TPidl from an LPITEMIDLIST (pidl)
891//
893 :Pidl(pidl)
894{
895}
896
897/// TPidl assignement operator (from another TPidl)
898//
899inline TPidl&
901{
902 if (&source == this)
903 return *this;
904 Pidl = source.CopyPidl();
905 return *this;
906}
907
908/// TPidl assignement operator (from an LPITEMIDLIST (pidl))
909//
910inline TPidl&
912{
913 FreePidl();
914 Pidl = pidl;
915 return *this;
916}
917
918/// TPidl destructor
919//
921{
922 FreePidl();
923}
924
925inline TPidl::operator LPCITEMIDLIST() const
926{
927 return Pidl;
928}
929
930inline TPidl::operator LPITEMIDLIST()
931{
932 return Pidl;
933}
934
935inline TPidl::operator LPCITEMIDLIST*() const
936{
937 return const_cast<LPCITEMIDLIST*>(&Pidl);
938}
939
940inline TPidl::operator LPITEMIDLIST*()
941{
942 if (Pidl)
943 FreePidl();
944 return &Pidl;
945}
946
947/// Return true if the TShellItem represents an item in the namespace
948//
949inline bool TShellItem::Valid() const
950{
951 return !!Pidl && !!ParentFolder;
952}
953
954// Attributes - Capabilties
955
956/// Return true if the TShellItem represents an item that can be copied
957//
958inline bool TShellItem::CanBeCopied(const bool validateCachedInfo) const
959{
961}
962
963/// Return true if the TShellItem represents an item that can be deleted
964//
969
970/// Return true if the TShellItem represents an item for which a shortcut can
971/// be created
972//
977
978/// Return true if the TShellItem represents an item that can be moved
979//
980inline bool TShellItem::CanBeMoved(const bool validateCachedInfo) const
981{
983}
984
985/// Return true if the TShellItem represents an item that can be renamed
986//
991
992/// Return true if the TShellItem represents an item is a drop target
993//
998
999/// Return true if the TShellItem represents an item that has a property sheet
1000//
1005
1006// Attributes - Display
1007
1008/// Return true if the TShellItem represents an item that should be displayed
1009/// as ghosted
1010//
1015
1016/// Return true if the TShellItem represents an item that is a shortcut
1017//
1018inline bool TShellItem::IsShortcut(const bool validateCachedInfo) const
1019{
1021}
1022
1023/// Return true if the TShellItem represents an item that is read only
1024//
1025inline bool TShellItem::IsReadOnly(const bool validateCachedInfo) const
1026{
1028}
1029
1030/// Return true if the TShellItem represents an item that is shared
1031//
1032inline bool TShellItem::IsShared(const bool validateCachedInfo) const
1033{
1035}
1036
1037// Attributes - Contents
1038
1039/// Return true if the TShellItem represents an item that contains a subfolder
1040//
1045
1046// Attributes - Miscellaneous
1047
1048/// Return true if the TShellItem represents an item that contains a file system folder
1049//
1054
1055/// Return true if the TShellItem represents an item that is part of the file system
1056//
1061
1062/// Return true if the TShellItem represents an item that is a folder
1063//
1064inline bool TShellItem::IsFolder(const bool validateCachedInfo) const
1065{
1067}
1068
1069/// Return true if the TShellItem represents an item that can be removed
1070//
1072{
1074}
1075
1076/// TShellItem::TCreateStruct default constructor
1077//
1081
1082/// TShellItem::TCreateStruct constructor (takes a TPidl and TComRef<IShellFolder>
1083//
1086:
1087 Pidl(pidl),
1088 ParentFolder(parentFolder)
1089{
1090}
1091
1092/// TShellItem::TCreateStruct copy constructor
1093//
1095:
1096Pidl(source.Pidl),
1097ParentFolder(source.ParentFolder)
1098{
1099}
1100
1101/// use TShellItem in place of an LPITEMIDLIST (pidl)
1102//
1103inline TShellItem::operator LPCITEMIDLIST() const
1104{
1105 return Pidl;
1106}
1107
1108/// Get a TShellItem's TPidl
1109//
1111{
1112 return Pidl; // Return a copy
1113}
1114
1115/// Compare sort order of this TShellItem equals another TShellItem
1116//
1117inline bool TShellItem::operator ==(const TShellItem& rhs) const
1118{
1119 return CompareIDs(rhs) == 0;
1120}
1121
1122/// Compare sort order of this TShellItem is less than another TShellItem
1123//
1124inline bool TShellItem::operator <(const TShellItem& rhs) const
1125{
1126 return CompareIDs(rhs) < 0;
1127}
1128
1129/// Compare sort order of this TShellItem is greater than another TShellItem
1130//
1131inline bool TShellItem::operator >(const TShellItem& rhs) const
1132{
1133 return CompareIDs(rhs) > 0;
1134}
1135
1136/// Compare sort order of this TShellItem is not equal to another TShellItem
1137//
1138inline bool TShellItem::operator !=(const TShellItem& rhs) const
1139{
1140 return !operator==(rhs);
1141}
1142
1143/// Compare sort order of this TShellItem <= another TShellItem
1144//
1145inline bool TShellItem::operator <=(const TShellItem& rhs) const
1146{
1147 return !operator>(rhs);
1148}
1149
1150/// Compare sort order of this TShellItem >= another TShellItem
1151//
1152inline bool TShellItem::operator >=(const TShellItem& rhs) const
1153{
1154 return !operator<(rhs);
1155}
1156
1157/// HaveSameParent returns true if this TShellItem and other TShellItem have the
1158/// same immediate parent folder.
1159//
1161{
1164
1165 return STATIC_CAST(IShellFolder*, constThis->ParentFolder) !=
1166 STATIC_CAST(IShellFolder*, constOther->ParentFolder);
1167}
1168
1169/// Return true if TShellItemIterator is valid and not at end of list of items
1170//
1171inline bool TShellItemIterator::Valid() const
1172{
1173 return Index != -1;
1174}
1175
1176} // OWL namespace
1177
1178#endif // OWL_SHELLITM_H
1179
TComRef< T > & operator=(T *iface)
Definition pointer.h:230
Wraps the IContextMenu interface (currently lightweight).
Definition shellitm.h:116
TContextMenu & operator=(const TComRef< IContextMenu > &source)
TContextMenu assignment operator (from TComRef<IContextMenu>)
Definition shellitm.h:768
TContextMenu(IContextMenu *iface=0)
Default constructor for TContextMenu.
Definition shellitm.h:746
Wraps the IDataObject interface (currently lightweight).
Definition shellitm.h:133
TDataObject(IDataObject *iface=0)
Default constructor for TDataObject.
Definition shellitm.h:787
TDataObject & operator=(const TComRef< IDataObject > &source)
TDataObject assignment operator (from TComRef<IDataObject>)
Definition shellitm.h:810
Wraps the IDropTarget interface (currently lightweight).
Definition shellitm.h:150
TDropTarget & operator=(const TComRef< IDropTarget > &source)
TDropTarget assignment operator (from TComRef<IDropTarget>)
Definition shellitm.h:851
TDropTarget(IDropTarget *iface=0)
Default constructor for TDropTarget.
Definition shellitm.h:829
Wraps the IExtractIcon interface (currently lightweight).
Definition shellitm.h:99
TExtractIcon(IExtractIcon *iface=0)
Default constructor for TExtractIcon.
Definition shellitm.h:705
TExtractIcon & operator=(const TComRef< IExtractIcon > &source)
TExtractIcon assignment operator (from TComRef<IExtractIcon>)
Definition shellitm.h:727
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPidl is an item identifier list class (ITEMIDLIST).
Definition shellitm.h:169
TPidl(LPITEMIDLIST pidl=0)
Construct a TPidl from an LPITEMIDLIST (pidl)
Definition shellitm.h:892
virtual ~TPidl()
TPidl destructor.
Definition shellitm.h:920
void FreePidl()
Free a pidl with the shell's allocator.
Definition shellitm.cpp:239
static LPITEMIDLIST Next(LPITEMIDLIST pidl)
Return next item id (in the list)
Definition shellitm.h:878
TPidl & operator=(const TPidl &source)
TPidl assignement operator (from another TPidl)
Definition shellitm.h:900
bool operator!() const
Check to see if TPidl represents an ITEMIDLIST (return true if it does not)
Definition shellitm.h:870
delay loading SHELL32.DLL/SHELL.DLL
Definition shellitm.h:50
static HRESULT SHGetMalloc(LPMALLOC *)
Invokes 'SHGetMalloc' indirectly.
Definition shellitm.cpp:186
An item in the shell's name space.
Definition shellitm.h:238
bool IsShortcut(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is a shortcut.
Definition shellitm.h:1018
bool CanBeRenamed(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be renamed.
Definition shellitm.h:987
bool ContainsSubFolder(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that contains a subfolder.
Definition shellitm.h:1041
bool HasAPropertySheet(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that has a property sheet.
Definition shellitm.h:1001
TIconKind
Used by TShellItem::GetIcon See MS doc for SHGetFileInfo for more information, Programmer's Guide to ...
Definition shellitm.h:262
bool ContainsFileSystemFolder(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that contains a file system folder.
Definition shellitm.h:1050
TBrowseFlags
Used by TShellItem::BrowseForFolder See MS doc for BROWSEINFO for more information,...
Definition shellitm.h:347
@ OnlyPrinters
Returns only printers.
Definition shellitm.h:349
@ OnlyFSAncestors
Returns only file system ancestors.
Definition shellitm.h:351
@ OnlyComputers
Returns only computers.
Definition shellitm.h:348
@ NoNetorkFoldersBelowDomain
Does not return network folders below the domain.
Definition shellitm.h:350
bool CanCreateShortcut(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item for which a shortcut can be created.
Definition shellitm.h:973
bool CanBeCopied(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be copied.
Definition shellitm.h:958
TExeKind
Returned by TShellItem::GetExeType See MS doc for SHGetFileInfo for more information,...
Definition shellitm.h:359
@ WindowsPE
Windows level (3.0, 3.5, or 4.0)
Definition shellitm.h:362
@ WindowsNE
Windows-based application.
Definition shellitm.h:361
@ MSDOS
MS-DOS .EXE, .COM, or .BAT file.
Definition shellitm.h:363
@ NonExecutable
Nonexecutable file or an error condition.
Definition shellitm.h:360
bool operator!=(const TShellItem &rhs) const
Compare sort order of this TShellItem is not equal to another TShellItem.
Definition shellitm.h:1138
bool CanBeRemoved(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be removed.
Definition shellitm.h:1071
bool DisplayGhosted(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that should be displayed as ghosted.
Definition shellitm.h:1011
bool operator<(const TShellItem &rhs) const
Compare sort order of this TShellItem is less than another TShellItem.
Definition shellitm.h:1124
bool operator==(const TShellItem &rhs) const
Compare sort order of this TShellItem equals another TShellItem.
Definition shellitm.h:1117
bool HaveSameParent(const TShellItem &other) const
HaveSameParent returns true if this TShellItem and other TShellItem have the same immediate parent fo...
Definition shellitm.h:1160
TIconSize
Used by TShellItem::GetIcon See MS doc for SHGetFileInfo for more information, Programmer's Guide to ...
Definition shellitm.h:252
TDisplayNameKind
Used by TShelItem::GetDisplayName() and TShellItem::Rename() See MS doc for SHGNO for more informatio...
Definition shellitm.h:244
TPidl GetPidl() const
Get TPidl (relative to parent)
Definition shellitm.h:1110
bool GetAttribute(const TAttribute at, const bool validateCachedInfo) const
GetAttribute is a protected function used by all the attribute functions except IsDesktop.
Definition shellitm.cpp:579
bool IsADropTarget(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item is a drop target.
Definition shellitm.h:994
TSpecialFolderKind
Used by TShellItem::TShellItem(const TSpecialFolderKind kind, HWND windowOwner = 0) See MS doc for SH...
Definition shellitm.h:273
bool CanBeDeleted(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be deleted.
Definition shellitm.h:965
bool IsShared(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is shared.
Definition shellitm.h:1032
bool IsReadOnly(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is read only.
Definition shellitm.h:1025
bool operator>(const TShellItem &rhs) const
Compare sort order of this TShellItem is greater than another TShellItem.
Definition shellitm.h:1131
bool IsPartOfFileSystem(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is part of the file system.
Definition shellitm.h:1057
bool IsFolder(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is a folder.
Definition shellitm.h:1064
bool operator<=(const TShellItem &rhs) const
Compare sort order of this TShellItem <= another TShellItem.
Definition shellitm.h:1145
TAttribute
Used by TShellItem::GetAttributes See MS doc for IShellFolder::GetAttributesOf for more information,...
Definition shellitm.h:297
@ atCanBeRenamed
The shell item can be renamed.
Definition shellitm.h:305
@ atIsFolder
The shell item is a folder.
Definition shellitm.h:326
@ atIsShortcut
The shell item is a shortcut.
Definition shellitm.h:313
@ atIsShared
The shell item is shared.
Definition shellitm.h:315
@ atDisplayGhosted
The shell item should be displayed using a ghosted icon.
Definition shellitm.h:312
@ atContainsSubFolder
The shell item has subfolders.
Definition shellitm.h:320
@ atIsReadOnly
The shell item is readonly.
Definition shellitm.h:314
@ atCanCreateShortcut
Shortcuts can be created for the shell item.
Definition shellitm.h:303
@ atCanBeDeleted
The shell item can be deleted.
Definition shellitm.h:302
@ atHasAPropertySheet
The shell item has a property sheet.
Definition shellitm.h:307
@ atIsPartOfFileSystem
The shell item is part of the file system.
Definition shellitm.h:325
@ atContainsFileSystemFolder
The shell item contains one or more system folders.
Definition shellitm.h:324
@ atCanBeRemoved
The shell item is on removable media.
Definition shellitm.h:327
@ atCanBeCopied
The shell item can be copied.
Definition shellitm.h:301
@ atIsADropTarget
The shell item is a drop target.
Definition shellitm.h:306
@ atCanBeMoved
The shell item can be moved.
Definition shellitm.h:304
bool Valid() const
Determine if TShellItem reprsents a valid item.
Definition shellitm.h:949
TFileOpFlags
Used by TShellItem::Rename,Copy,Move,Delete See MS doc for SHFILEOPSTRUCT for more information,...
Definition shellitm.h:334
bool CanBeMoved(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be moved.
Definition shellitm.h:980
bool operator>=(const TShellItem &rhs) const
Compare sort order of this TShellItem >= another TShellItem.
Definition shellitm.h:1152
short CompareIDs(const TShellItem &rhs) const
CompareIDs is a protected function that compares a TShellItem's pidl with another TShellItem's pidl.
TShellItemIterator is an interator for walking through the contents of a folder.
Definition shellitm.h:565
TIncludeKind
Used by TShellItemIterator::TShellItemIterator(const TShellItem& folder, HWND windowOwner = 0,...
Definition shellitm.h:571
bool Valid() const
True if iterator is still valid.
Definition shellitm.h:1171
Wraps the shell's IMalloc interface.
Definition shellitm.h:82
TShellMalloc()
Default constructor for TShellMalloc.
Definition shellitm.h:663
TShellMalloc & operator=(const TComRef< IMalloc > &source)
TShellMalloc assignment operator (from TComRef<IMalloc>)
Definition shellitm.h:686
Reference to reference counted string object TUString Lightweight reference object consisting of a po...
Definition string.h:67
TXOwl is root class of the ObjectWindows exception hierarchy.
Definition except.h:38
Base Shell exception class. Handles all TShellItem and related class exceptions.
Definition shellitm.h:628
static void Check(HRESULT hr, uint resId=IDS_SHELLFAILURE, HANDLE handle=0)
Checks an HResult and throws a TXShell if not SUCCEEDED(hr).
int operator!=(const TBitSet< T > &bs1, const TBitSet< T > &bs2)
Definition bitset.h:111
int operator==(const TBitSet< T > &bs1, const TBitSet< T > &bs2)
Definition bitset.h:86
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
auto operator>=(const TCodePages::TCodePage &lhs, const TCodePages::TCodePage &rhs) -> bool
unsigned long ulong
Definition number.h:26
char tchar
Definition defs.h:77
auto operator>(const TCodePages::TCodePage &lhs, const TCodePages::TCodePage &rhs) -> bool
unsigned int uint
Definition number.h:25
General definitions used by all ObjectWindows programs.
#define protected_data
Definition defs.h:208
ObjectWindows exception class & function definitions.
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define _OWLCLASS
Definition defs.h:338
#define STATIC_CAST(targetType, object)
Definition defs.h:271
Various types of smart pointer templatized classes.
Definition of class TString, a flexible universal string envelope class.
TCreateStruct contains information to construct a TShellItem Typically a TCreateStruct is returned (f...
Definition shellitm.h:385
TCreateStruct()
TShellItem::TCreateStruct default constructor.
Definition shellitm.h:1078
TComRef< IShellFolder > ParentFolder
Definition shellitm.h:391