OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
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 ///
345 /// See the Windows API documentation for `BROWSEINFO.ulFlags` for more information about these
346 /// flags, as well as additional flags that may be used.
347 ///
348 /// \sa <a href="https://learn.microsoft.com/windows/win32/api/shlobj_core/ns-shlobj_core-browseinfow" target="blank_">
349 /// ::%BROWSEINFO</a>
350 //
352 {
353 OnlyComputers = BIF_BROWSEFORCOMPUTER, ///< Returns only computers.
354 OnlyPrinters = BIF_BROWSEFORPRINTER, ///< Returns only printers.
355 NoNetorkFoldersBelowDomain = BIF_DONTGOBELOWDOMAIN, ///< Does not return network folders below the domain.
356 OnlyFSAncestors = BIF_RETURNFSANCESTORS, ///< Returns only file system ancestors.
357 OnlyFSDirs = BIF_RETURNONLYFSDIRS ///< Returns only file system directories.
358 };
359
360 /// Returned by TShellItem::GetExeType
361 /// See MS doc for SHGetFileInfo for more information, Programmer's
362 /// Guide to MS Windows 95, MS Press, pp. 205-207.
363 //
364 enum TExeKind {
365 NonExecutable, ///< Nonexecutable file or an error condition
366 WindowsNE, ///< Windows-based application
367 WindowsPE, ///< Windows level (3.0, 3.5, or 4.0)
368 MSDOS, ///< MS-DOS .EXE, .COM, or .BAT file
369 Win32Console ///< Win32-based console application
370 };
371
372 /// TCreateStruct contains information to construct a TShellItem
373 /// Typically a TCreateStruct is returned (for example by GetParentFolder)
374 /// and this TCreateStruct is used to construct a TshellItem
375 /// Passed in as arguments to:
376 /// - TShellItem::TShellItem(const TCreateStruct& cs)
377 /// - TShellItem::operator =(const TCreateStruct& cs)
378 /// Returned as an out argument by:
379 /// - TShellItem::BrowseForFolder
380 /// - TShellItem::ParseDisplayName
381 /// Returned by:
382 /// - TShellItem::GetParentFolder
383 /// - TShellItemIterator::operator ++ ();
384 /// - TShellItemIterator::operator ++ (int);
385 /// - TShellItemIterator::operator -- ();
386 /// - TShellItemIterator::operator -- (int);
387 /// - TShellItemIterator::operator [] (const long index);
388 /// - TShellItemIterator::Current();
389 //
398
399 // Constructors for TShellItem
400 //
401 TShellItem(const tchar* path, bool throwOnInvalidPath = true, HWND windowOwner = 0);
403 TShellItem(const TCreateStruct& cs); // used with TShellItemIterator
407
408 // Assignment operators
409 //
412
413 /// Determine if TShellItem reprsents a valid item
414 //
415 bool Valid() const;
416
417 /// Allow TShellItems to be used in place of pidls
418 operator LPCITEMIDLIST() const; // 05/26/98 Yura Bidus
419
420 // Get TExtractIcon, TContextMenu, TDataObject, TDropTarget for a TShellItem
421 TExtractIcon GetExtractIcon(HWND windowOwner = 0);
422 TContextMenu GetContextMenu(HWND windowOwner = 0);
423 TDataObject GetDataObject(HWND windowOwner = 0);
424 TDropTarget GetDropTarget(HWND windowOwner = 0);
425 HICON GetIcon(TIconSize size = Shell, uint kind = 0);
426
427 /// Get Attributes of a TShellItem
428 /// GetAttributes - Get Capabilities, Display, Contents, & Misc. Attributes with one call
429 //
430 ulong GetAttributes(const ulong reqAttrib, const bool validateCachedInfo = false) const;
431
432 // Attributes - Capabilties
433 //
434 bool CanBeCopied(const bool validateCachedInfo = false) const;
435 bool CanBeDeleted(const bool validateCachedInfo = false) const;
436 bool CanCreateShortcut(const bool validateCachedInfo = false) const;
437 bool CanBeMoved(const bool validateCachedInfo = false) const;
438 bool CanBeRenamed(const bool validateCachedInfo = false) const;
439 bool IsADropTarget(const bool validateCachedInfo = false) const;
440 bool HasAPropertySheet(const bool validateCachedInfo = false)const;
441
442 // Attributes - Display
443 //
444 bool DisplayGhosted(const bool validateCachedInfo = false) const;
445 bool IsShortcut(const bool validateCachedInfo = false) const;
446 bool IsReadOnly(const bool validateCachedInfo = false) const;
447 bool IsShared(const bool validateCachedInfo = false) const;
448
449 // Attributes - Contents
450 //
451 bool ContainsSubFolder(const bool validateCachedInfo = false) const;
452
453 // Attributes - Miscellaneous
454 //
455 bool ContainsFileSystemFolder(const bool validateCachedInfo = false) const;
456 bool IsPartOfFileSystem(const bool validateCachedInfo = false) const;
457 bool IsFolder(const bool validateCachedInfo = false) const;
458 bool CanBeRemoved(const bool validateCachedInfo = false) const;
459
460 // Attributes - Additional (Not part of GetAttributes)
461 //
462 bool IsDesktop() const;
463
464 /// Get TPidl (relative to parent)
465 //
466 TPidl GetPidl() const;
467
468 /// Get fully qualified TPidl
469 //
470 TPidl GetFullyQualifiedPidl() const;
471
472 /// Get Parent Folder
473 //
474 TCreateStruct GetParentFolder() const;
475
476 /// Get type of executable file (may return NonExecutable)
477 //
478 TExeKind GetExeType(uint* major = 0, uint* minor = 0) const;
479
480 /// Get type of file (e.g., "Borland C++ Header File", "Notepad File")
481 //
482 TString GetTypeName() const;
483
484 /// Get Displayname (for a TShellItem that's part of the filesystem, this is the filename)
485 //
486 TString GetDisplayName(const TDisplayNameKind kind = Normal) const;
487
488 /// Get path (only call if the TShellItem is part of the file system (IsPartOfFileSystem == true)
489 //
490 TString GetPath() const;
491
492 // File Opertations (Rename, Copy, Move, Delete)
493 //
494 void Rename(const tchar* newName, HWND windowOwner = 0,
495 const TDisplayNameKind kind = Normal);
496 bool Copy(const tchar* dest, const bool destIsFolder = true,
497 const USHORT flags = 0, const tchar* title = 0,
498 HWND windowOwner = 0) const;
499 bool Copy(const TShellItem& dest, const USHORT flags = 0, const tchar* title = 0,
500 HWND windowOwner = 0) const;
501 bool Move(const tchar* destFolder, const USHORT flags = 0,
502 const tchar* title = 0, HWND windowOwner = 0);
503 bool Move(const TShellItem& destFolder, const USHORT flags = 0,
504 const tchar* title = 0, HWND windowOwner = 0);
505 bool Delete(const USHORT flags = 0, const tchar* title = 0,
506 HWND windowOwner = 0);
507
508 /// Add to recent docs (Win95 taskbar:Start:Documents)
509 //
510 void AddToRecentDocs() const;
511
512 /// Get the TShellItem that a shortcut points to
513 //
514 TShellItem ResolveShortcut(HWND windowOwner = 0);
515
516 // Create a shortcut
517 // TODO: Add string-aware overloads.
518 //
519 static HRESULT CreateShortCut(LPCTSTR objPath, LPTSTR pathLink,
520 LPTSTR description);
521 static HRESULT CreateShortCut(LPCITEMIDLIST pidl, LPTSTR pathLink,
522 LPTSTR description);
523 TShellItem CreateShortCut(LPTSTR pathLink, LPTSTR description);
524
525 // Pidl compares (so that they can be ordered)
526 //
527 bool operator==(const TShellItem& rhs) const;
528 bool operator!=(const TShellItem& rhs) const;
529 bool operator<(const TShellItem& rhs) const;
530 bool operator<=(const TShellItem& rhs) const;
531 bool operator>(const TShellItem& rhs) const;
532 bool operator>=(const TShellItem& rhs) const;
533
534 // Folder Only Functions
535 // EnumObjects is called by TShellItemIterator
536 //
537 void EnumObjects(IEnumIDList** iface, HWND windowOwner = 0,
538 const int kind = -1) const;
539 /// Select a Foler under this TShellItem
540 //
541 bool BrowseForFolder(TCreateStruct& cs, HWND windowOwner = 0,
542 const tchar* title = 0, const UINT flags = 0,
543 int* image = 0, const bool includeStatus = false,
544 BFFCALLBACK func = 0, const LPARAM param = 0) const;
545
546 /// Parse a display name into a TShellItem (actually, into a TCreateStruct)
547 //
548 HRESULT ParseDisplayName(TCreateStruct& cs, const tchar* displayName,
549 ulong* eaten = nullptr, HWND windowOwner = nullptr,
550 ulong* attrib = nullptr) const;
551 protected:
552 // CompareIDs is used by the pidl compare functions above
553 //
554 short CompareIDs(const TShellItem& rhs) const;
555 void EnforceValidity() const;
556 void RetrieveIShellFolder() const;
557 bool HaveSameParent(const TShellItem& other) const;
558 bool GetAttribute(const TAttribute at, const bool validateCachedInfo) const;
560 TPidl Pidl;
561 TComRef<IShellFolder> ParentFolder;
562};
563
564//
565/// \class TShellItemIterator
566// ~~~~~ ~~~~~~~~~~~~~~~~~~
567/// TShellItemIterator is an interator for walking through the contents of a folder.
568/// A folder is a TShellItem whose IsFolder or ContainsSubFolder attributes are true.
569//
570class _OWLCLASS TShellItemIterator: public TComRef<IEnumIDList> {
571 public:
572 /// Used by TShellItemIterator::TShellItemIterator(const TShellItem& folder,
573 /// HWND windowOwner = 0, const UINT kind = Folders | NonFolders)
574 /// See MS doc for SHCONTF for more information, Programmer's Guide to
575 /// MS Windows 95, MS Press, p. 213.
577 Folders = SHCONTF_FOLDERS, ///< For shell browser
578 NonFolders = SHCONTF_NONFOLDERS, ///< For default view
579 HiddenAndSystem = SHCONTF_INCLUDEHIDDEN ///< For hidden or system objects
580 };
581
582 // constructor for TShellItemIterator
583 //
585 const int kind = Folders | NonFolders);
587
588 /// Assignment operator
589 //
591
592 /// True if iterator is still valid
593 //
594 bool Valid() const;
595
596 /// Get number of TShellItems in the list
597 //
598 long GetCount() const;
599
600 // Get next item, previous item, item at index, and current item
601 //
606 TShellItem::TCreateStruct operator [] (const long index);
608
609 /// Skip count items
610 //
611 void Skip(const ulong count);
612
613 /// Reset list
614 //
615 void Reset();
616
617 protected:
618 void Next();
619 void EnforceValidInterface() const;
620
622 long Index;
623 TPidl Pidl;
625 operator IEnumIDList**();
626};
627
628//
629/// \class TXShell
630// ~~~~~ ~~~~~~~
631/// Base Shell exception class. Handles all TShellItem and related class exceptions
632//
633class _OWLCLASS TXShell: public TXOwl {
634 public:
635 // Constructor for TXShell
636 //
638
639 // Clone a TXShell
640 //
641 TXShell* Clone();
642
643 // Throw an exception
644 //
645 void Throw();
646
647 // Construct a TXShell exception from scratch, and throw it.
648 //
649 static void Raise(uint resId = IDS_SHELLFAILURE, HANDLE handle = 0);
650
651 // Check an HRESULT and throw a TXShell if not SUCCEEDED(hr)
652 //
653 static void Check(HRESULT hr, uint resId = IDS_SHELLFAILURE, HANDLE handle = 0);
654};
655
656/// @}
657
658#include <owl/posclass.h>
659
660
661//----------------------------------------------------------------------------
662// Inline implementations
663//
664
665/// Default constructor for TShellMalloc. For more info, see MS doc for
666/// SHGetMalloc (Prog. Guide to MS Win95, p. 208)
667//
673
674/// TShellMalloc constructor to construct from TComRef<IMalloc>
675//
680
681/// TShellMalloc copy constructor
682//
687
688/// TShellMalloc assignment operator (from TComRef<IMalloc>)
689//
690inline TShellMalloc&
692{
693 if (&source != this)
695 return *this;
696}
697
698/// TShellMalloc assignment operator (from another TShellMalloc)
699//
700inline TShellMalloc&
702{
703 if (&source != this)
705 return *this;
706}
707
708/// Default constructor for TExtractIcon
709//
714
715/// TExtractIcon constructor to construct from TComRef<IExtractIcon>
716//
721
722/// TExtractIcon copy constructor
723//
728
729/// TExtractIcon assignment operator (from TComRef<IExtractIcon>)
730//
731inline TExtractIcon&
733{
734 if (&source != this)
736 return *this;
737}
738
739/// TExtractIcon assignment operator (from another TExtractIcon)
740//
741inline TExtractIcon&
743{
744 if (&source != this)
746 return *this;
747}
748
749/// Default constructor for TContextMenu
750//
755
756/// TContextMenu constructor to construct from TComRef<IContextMenu>
757//
762
763/// TContextMenu copy constructor
764//
769
770/// TContextMenu assignment operator (from TComRef<IContextMenu>)
771//
772inline TContextMenu&
774{
775 if (&source != this)
777 return *this;
778}
779
780/// TContextMenu assignment operator (from another TContextMenu)
781//
782inline TContextMenu&
784{
785 if (&source != this)
787 return *this;
788}
789
790/// Default constructor for TDataObject
791//
797
798/// TDataObject constructor to construct from TComRef<IDataObject>
799//
804
805/// TDataObject copy constructor
806//
811
812/// TDataObject assignment operator (from TComRef<IDataObject>)
813//
814inline TDataObject&
816{
817 if (&source != this)
819 return *this;
820}
821
822/// TDataObject assignment operator (from another TDataObject)
823//
824inline TDataObject&
826{
827 if (&source != this)
829 return *this;
830}
831
832/// Default constructor for TDropTarget
833//
838
839/// TDropTarget constructor to construct from TComRef<IDropTarget>
840//
845
846/// TDropTarget copy constructor
847//
852
853/// TDropTarget assignment operator (from TComRef<IDropTarget>)
854//
855inline TDropTarget&
857{
858 if (&source != this)
860 return *this;
861}
862
863/// TDropTarget assignment operator (from another TDropTarget)
864//
865inline TDropTarget&
867{
868 if (&source != this)
870 return *this;
871}
872
873/// Check to see if TPidl represents an ITEMIDLIST (return true if it does not)
874//
875inline bool TPidl::operator !() const
876{
877 return Pidl == nullptr;
878}
879
880/// Return next item id (in the list)
881//
882inline LPITEMIDLIST
884{
885 return reinterpret_cast<LPITEMIDLIST>(reinterpret_cast<char*>(pidl) + pidl->mkid.cb);
886}
887
888/// TPidl copy constructor
889//
891 :Pidl(source.CopyPidl())
892{
893}
894
895/// Construct a TPidl from an LPITEMIDLIST (pidl)
896//
898 :Pidl(pidl)
899{
900}
901
902/// TPidl assignement operator (from another TPidl)
903//
904inline TPidl&
906{
907 if (&source == this)
908 return *this;
909 Pidl = source.CopyPidl();
910 return *this;
911}
912
913/// TPidl assignement operator (from an LPITEMIDLIST (pidl))
914//
915inline TPidl&
917{
918 FreePidl();
919 Pidl = pidl;
920 return *this;
921}
922
923/// TPidl destructor
924//
926{
927 FreePidl();
928}
929
930inline TPidl::operator LPCITEMIDLIST() const
931{
932 return Pidl;
933}
934
935inline TPidl::operator LPITEMIDLIST()
936{
937 return Pidl;
938}
939
940inline TPidl::operator LPCITEMIDLIST*() const
941{
942 return const_cast<LPCITEMIDLIST*>(&Pidl);
943}
944
945inline TPidl::operator LPITEMIDLIST*()
946{
947 if (Pidl)
948 FreePidl();
949 return &Pidl;
950}
951
952/// Return true if the TShellItem represents an item in the namespace
953//
954inline bool TShellItem::Valid() const
955{
956 return !!Pidl && !!ParentFolder;
957}
958
959// Attributes - Capabilties
960
961/// Return true if the TShellItem represents an item that can be copied
962//
963inline bool TShellItem::CanBeCopied(const bool validateCachedInfo) const
964{
966}
967
968/// Return true if the TShellItem represents an item that can be deleted
969//
974
975/// Return true if the TShellItem represents an item for which a shortcut can
976/// be created
977//
982
983/// Return true if the TShellItem represents an item that can be moved
984//
985inline bool TShellItem::CanBeMoved(const bool validateCachedInfo) const
986{
988}
989
990/// Return true if the TShellItem represents an item that can be renamed
991//
996
997/// Return true if the TShellItem represents an item is a drop target
998//
1000{
1002}
1003
1004/// Return true if the TShellItem represents an item that has a property sheet
1005//
1010
1011// Attributes - Display
1012
1013/// Return true if the TShellItem represents an item that should be displayed
1014/// as ghosted
1015//
1020
1021/// Return true if the TShellItem represents an item that is a shortcut
1022//
1023inline bool TShellItem::IsShortcut(const bool validateCachedInfo) const
1024{
1026}
1027
1028/// Return true if the TShellItem represents an item that is read only
1029//
1030inline bool TShellItem::IsReadOnly(const bool validateCachedInfo) const
1031{
1033}
1034
1035/// Return true if the TShellItem represents an item that is shared
1036//
1037inline bool TShellItem::IsShared(const bool validateCachedInfo) const
1038{
1040}
1041
1042// Attributes - Contents
1043
1044/// Return true if the TShellItem represents an item that contains a subfolder
1045//
1050
1051// Attributes - Miscellaneous
1052
1053/// Return true if the TShellItem represents an item that contains a file system folder
1054//
1059
1060/// Return true if the TShellItem represents an item that is part of the file system
1061//
1066
1067/// Return true if the TShellItem represents an item that is a folder
1068//
1069inline bool TShellItem::IsFolder(const bool validateCachedInfo) const
1070{
1072}
1073
1074/// Return true if the TShellItem represents an item that can be removed
1075//
1077{
1079}
1080
1081/// TShellItem::TCreateStruct default constructor
1082//
1086
1087/// TShellItem::TCreateStruct constructor (takes a TPidl and TComRef<IShellFolder>
1088//
1091:
1092 Pidl(pidl),
1093 ParentFolder(parentFolder)
1094{
1095}
1096
1097/// TShellItem::TCreateStruct copy constructor
1098//
1100:
1101Pidl(source.Pidl),
1102ParentFolder(source.ParentFolder)
1103{
1104}
1105
1106/// use TShellItem in place of an LPITEMIDLIST (pidl)
1107//
1108inline TShellItem::operator LPCITEMIDLIST() const
1109{
1110 return Pidl;
1111}
1112
1113/// Get a TShellItem's TPidl
1114//
1116{
1117 return Pidl; // Return a copy
1118}
1119
1120/// Compare sort order of this TShellItem equals another TShellItem
1121//
1122inline bool TShellItem::operator ==(const TShellItem& rhs) const
1123{
1124 return CompareIDs(rhs) == 0;
1125}
1126
1127/// Compare sort order of this TShellItem is less than another TShellItem
1128//
1129inline bool TShellItem::operator <(const TShellItem& rhs) const
1130{
1131 return CompareIDs(rhs) < 0;
1132}
1133
1134/// Compare sort order of this TShellItem is greater than another TShellItem
1135//
1136inline bool TShellItem::operator >(const TShellItem& rhs) const
1137{
1138 return CompareIDs(rhs) > 0;
1139}
1140
1141/// Compare sort order of this TShellItem is not equal to another TShellItem
1142//
1143inline bool TShellItem::operator !=(const TShellItem& rhs) const
1144{
1145 return !operator==(rhs);
1146}
1147
1148/// Compare sort order of this TShellItem <= another TShellItem
1149//
1150inline bool TShellItem::operator <=(const TShellItem& rhs) const
1151{
1152 return !operator>(rhs);
1153}
1154
1155/// Compare sort order of this TShellItem >= another TShellItem
1156//
1157inline bool TShellItem::operator >=(const TShellItem& rhs) const
1158{
1159 return !operator<(rhs);
1160}
1161
1162/// HaveSameParent returns true if this TShellItem and other TShellItem have the
1163/// same immediate parent folder.
1164//
1166{
1169
1170 return STATIC_CAST(IShellFolder*, constThis->ParentFolder) !=
1171 STATIC_CAST(IShellFolder*, constOther->ParentFolder);
1172}
1173
1174/// Return true if TShellItemIterator is valid and not at end of list of items
1175//
1176inline bool TShellItemIterator::Valid() const
1177{
1178 return Index != -1;
1179}
1180
1181} // OWL namespace
1182
1183#endif // OWL_SHELLITM_H
1184
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:773
TContextMenu(IContextMenu *iface=0)
Default constructor for TContextMenu.
Definition shellitm.h:751
Wraps the IDataObject interface (currently lightweight).
Definition shellitm.h:133
TDataObject(IDataObject *iface=0)
Default constructor for TDataObject.
Definition shellitm.h:792
TDataObject & operator=(const TComRef< IDataObject > &source)
TDataObject assignment operator (from TComRef<IDataObject>)
Definition shellitm.h:815
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:856
TDropTarget(IDropTarget *iface=0)
Default constructor for TDropTarget.
Definition shellitm.h:834
Wraps the IExtractIcon interface (currently lightweight).
Definition shellitm.h:99
TExtractIcon(IExtractIcon *iface=0)
Default constructor for TExtractIcon.
Definition shellitm.h:710
TExtractIcon & operator=(const TComRef< IExtractIcon > &source)
TExtractIcon assignment operator (from TComRef<IExtractIcon>)
Definition shellitm.h:732
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:78
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:897
virtual ~TPidl()
TPidl destructor.
Definition shellitm.h:925
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:883
TPidl & operator=(const TPidl &source)
TPidl assignement operator (from another TPidl)
Definition shellitm.h:905
bool operator!() const
Check to see if TPidl represents an ITEMIDLIST (return true if it does not)
Definition shellitm.h:875
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:1023
bool CanBeRenamed(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be renamed.
Definition shellitm.h:992
bool ContainsSubFolder(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that contains a subfolder.
Definition shellitm.h:1046
bool HasAPropertySheet(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that has a property sheet.
Definition shellitm.h:1006
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:1055
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:978
bool CanBeCopied(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be copied.
Definition shellitm.h:963
TExeKind
Returned by TShellItem::GetExeType See MS doc for SHGetFileInfo for more information,...
Definition shellitm.h:364
@ WindowsPE
Windows level (3.0, 3.5, or 4.0)
Definition shellitm.h:367
@ WindowsNE
Windows-based application.
Definition shellitm.h:366
@ MSDOS
MS-DOS .EXE, .COM, or .BAT file.
Definition shellitm.h:368
@ NonExecutable
Nonexecutable file or an error condition.
Definition shellitm.h:365
bool operator!=(const TShellItem &rhs) const
Compare sort order of this TShellItem is not equal to another TShellItem.
Definition shellitm.h:1143
bool CanBeRemoved(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be removed.
Definition shellitm.h:1076
bool DisplayGhosted(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that should be displayed as ghosted.
Definition shellitm.h:1016
bool operator<(const TShellItem &rhs) const
Compare sort order of this TShellItem is less than another TShellItem.
Definition shellitm.h:1129
bool operator==(const TShellItem &rhs) const
Compare sort order of this TShellItem equals another TShellItem.
Definition shellitm.h:1122
bool HaveSameParent(const TShellItem &other) const
HaveSameParent returns true if this TShellItem and other TShellItem have the same immediate parent fo...
Definition shellitm.h:1165
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:1115
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:999
TSpecialFolderKind
Used by TShellItem::TShellItem(const TSpecialFolderKind kind, HWND windowOwner = 0) See MS doc for SH...
Definition shellitm.h:273
TBrowseFlags
Used by TShellItem::BrowseForFolder.
Definition shellitm.h:352
bool CanBeDeleted(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that can be deleted.
Definition shellitm.h:970
bool IsShared(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is shared.
Definition shellitm.h:1037
bool IsReadOnly(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is read only.
Definition shellitm.h:1030
bool operator>(const TShellItem &rhs) const
Compare sort order of this TShellItem is greater than another TShellItem.
Definition shellitm.h:1136
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:1062
bool IsFolder(const bool validateCachedInfo=false) const
Return true if the TShellItem represents an item that is a folder.
Definition shellitm.h:1069
bool operator<=(const TShellItem &rhs) const
Compare sort order of this TShellItem <= another TShellItem.
Definition shellitm.h:1150
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:954
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:985
bool operator>=(const TShellItem &rhs) const
Compare sort order of this TShellItem >= another TShellItem.
Definition shellitm.h:1157
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:570
TIncludeKind
Used by TShellItemIterator::TShellItemIterator(const TShellItem& folder, HWND windowOwner = 0,...
Definition shellitm.h:576
bool Valid() const
True if iterator is still valid.
Definition shellitm.h:1176
Wraps the shell's IMalloc interface.
Definition shellitm.h:82
TShellMalloc()
Default constructor for TShellMalloc.
Definition shellitm.h:668
TShellMalloc & operator=(const TComRef< IMalloc > &source)
TShellMalloc assignment operator (from TComRef<IMalloc>)
Definition shellitm.h:691
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:633
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:390
TCreateStruct()
TShellItem::TCreateStruct default constructor.
Definition shellitm.h:1083
TComRef< IShellFolder > ParentFolder
Definition shellitm.h:396