Writing Shell Namespace Extensions Krishna Kotipalli Microsoft Product Support PowerPoint PPT Presentation

presentation player overlay
1 / 21
About This Presentation
Transcript and Presenter's Notes

Title: Writing Shell Namespace Extensions Krishna Kotipalli Microsoft Product Support


1
Writing Shell Namespace Extensions Krishna
KotipalliMicrosoft Product Support
2
Objectives
  • Understand what a Shell Namespace is
  • Learn how to extend the Shell Namespace
  • Understand the various COM interfaces related to
    extending the Shell Namespace

3
Prerequisites
  • Microsoft Win32 programming
  • Knowledge of COM

4
Shell Namespace
  • What is a Shell Namespace?
  • Type of Shell Namespace
  • Examples of Shell Namespace

5
Extending the Shell Namespace
  • Why to extend the Shell Namespace?
  • What can be done?
  • What cannot be done?

6
PIDL
  • What is a pidl?
  • ITEMIDLIST
  • typedef struct _ITEMIDLIST
  • SHITEMID mkid
  • ITEMIDLIST
  • SHITEMID
  • typedef struct _SHITEMID
  • USHORT cb // size of the ID (including cb
    itself)
  • BYTE abID1 // The item ID (variable length)
  • SHITEMID

7
PIDL (continued)
PIDL
  • A pidl to C\Pics\MtRainier.jpg would be

Remember PIDLs are OPAQUE
PIDLs should always be allocated with Shells
Memory allocator (obtained via SHGetMalloc)
8
Some Shell Namespace Related Interfaces
  • IShellBrowser
  • IShellFolder
  • IShellView
  • IEnumIDList

9
IShellFolder Methods
  • BindToObject retrieves IShellFolder interface
    for the specified subfolder
  • BindToStorage returns the storage instance of a
    subfolder. Not implemented currently
  • CompareIDs Determines relative order of two
    file/folder objects, given their item identifier
    lists
  • CreateViewObject Creates a view object of the
    folder itself
  • EnumObjects Enumerates the objects in a folder
  • GetAttributesOf Retrieves the attributes of the
    specified file object or subfolder.
  • GetDisplayNameOf Retrieves the display name of a
    file object or subfolder
  • GetUIObjectOf Creates an OLE interface that can
    be used to carry out operations on a file object
    (or objects) or subfolder(s).
  • ParseDisplayName Translates a display name into
    an item identifier list.
  • SetNameOf Sets the display name of the specified
    file object or subfolder and changes its
    identifier accordingly.

10
IShellView Methods
  • AddPropertySheetPages Allows the view to add
    pages to the Options property sheet.
  • CreateViewWindow Creates the view window.
  • DestroyViewWindow Destroys the view window
  • EnableModeless Enables or disables modeless
    dialog boxes. Not in use.
  • EnableModelessSV Not in use.
  • GetCurrentInfo Returns the current folder
    settings
  • GetItemObject Allows callers to get an object
    that represents something in the view.
  • Refresh Refreshes the display in response to
    user input.
  • SaveViewState Saves the shells view setting
  • SelectItem Changes the state of items within the
    shell view window
  • TransalteAccelerator Translates accelerator key
    strokes when the view has the focus.
  • UIActivate Called whenever the activation state
    of the view windows is changed by an event not
    caused by the shell view itself.

11
IEnumIDList Methods
  • Clone Creates a new item enumeration object
    identical to the current one.
  • Next Retrieves the specified number of item
    identifiers.
  • Reset Returns to the beginning of the
    enumeration.
  • Skip Skips over the specified number of items.

12
IShellBrowser Methods
  • BrowseObject Tells the container to browse in
    another folder.
  • EnableModelessSB Enables or disables modeless
    windows of the container.
  • GetControlWindow Gets the window handle to the
    container.
  • GetViewStateStream Returns a view-specific
    stream that can be used to read and write the
    persistent data for a view.
  • InsertMenusSB Inserts menu items to an empty
    menu created by the view.
  • OnViewWindowActive Informs that the view was
    activated.
  • QueryActiveShellView Returns the currently
    activated shell view object.
  • RemoveMenusSB Instructs the container to remove
    its items from a composite menu.
  • SendControlMsg Sends messages to the containers
    controls.
  • SetMenuSB Installs the composite menu in the
    container.
  • SetStatusTextSB Sets and displays status text
    for the container.
  • SetToolbarItems Adds toolbar items to the
    containers toolbar.
  • TranslateAcceleratorSB reserved for future use.

13
An Example
  • Display context menu given a filesystem
    file/folder path.
  • Get the parent folder.
  • Obtain the IShellFolder for the parent folder.
  • Get the pidl to the file name with respect to the
    parent folders IShellFolder
  • Get the IContextMenu interface for the parent
    folder by calling IShellFolderGetUIObjectOf
    with riidIID_IContextMenu
  • Get the HMENU by calling QueryContextMenu with
    the pidl to the (child) file/folder name
  • Display the context menu using TrackPopupMenu
  • More information is available in KB article
    Q198288.

14
A Shell Namespace Extension
  • COM in-proc server
  • DllGetClassObject
  • DllCanUnloadNow
  • DllRegisterServer
  • DllUnregisterServer
  • Registry Entries
  • HKEY_CLASSES_ROOT\CLSID\CLSID
  • DefaultIcon
  • Default REG_SZ
  • ShellFolder
  • Attributes REG_BIN
  • Admin privileges on Windows NT,
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Cur
    rentVersion\Shell Extensions\ Approved
  • CLSID REG_SZ

15
Junction Point
  • On Desktop or My Computer
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Cur
    rentVersion\Explorer
  • Desktop\Namespace\CLSID
  • Default REG_SZ
  • MyComputer\Namespace\CLSID
  • Default REG_SZ
  • Folder.CLSID method
  • Desktop.ini method

16
An Empty Shell Namespace Extension
  • Support self-registration
  • IShellFolder implementation
  • Return a pointer to implementation of
    IShellFolder in response to DllGetClassObject
    (with REFIID of IID_IShellFolder)
  • Handle initializations via IShellFolderInitializ
    e
  • Handle IShellFolderCreateViewObject by creating
    an instance of IShellView object
  • IShellView implementation
  • Create a window in response to IShellViewCreateV
    iewWindow

17
A Basic Shell Namespace Extension
  • Support self-registration
  • Data structure for the items
  • IEnumIDList implementation
  • IShellFolder implementation
  • IShellFolderInitialize
  • IShellFolderEnumObjects
  • IShellFolderCreateViewObject
  • IShellFolderGetDisplayNameOf
  • IShellView implementation
  • IShellViewCreateViewWindow
  • Create the view window (usually a list control),
    initialize, populate
  • Delegate idlist related calls to the parent
    ShellFolder
  • Handle selection, mouse events, and so forth.

18
A Functional Shell Namespace Extension
  • IShellFolder
  • GetAttributesOf
  • BindToObject
  • CompareIDs
  • IShellView
  • UIActivate
  • IShellBrowser
  • SendControlMsg
  • InsertMenusSB
  • RemoveMenusSB
  • SetToolbarItems

19
Summary
  • Shell Namespace Architecture
  • IShellBrowser, IShellFolder, IShellView,
    IEnumIDList et al
  • Data hiding using PIDLs
  • IShellFolder - IShellView - IShellBrowser
    interaction

20
Resources
  • http//msdn.microsoft.com/library/sdkdoc/shellcc/s
    hell/namespace.htm
  • http//www.microsoft.com/mind/0399/faq/faq0399.htm
    (article plus the AppWizard to generate Shell
    NameSpace Extensions)
  • Knowledge Base articles
  • Q198288 - HOWTO Displaying Context Menu Given
    the Path to a File
  • Q216954 - HOWTO Support Common Dialog Browsing
    in a Shell Namespace Extension
  • Q183860 - HOWTO Support Dropping of Items on
    Your Namespace Root
  • Q179900 - HOWTO Support Renaming of Items in the
    Windows Explorer Tree
  • Q182379 - HOWTO Support Toolbar Item Text in a
    Shell Namespace Extension
  • Q198871 - PRB IShellFolderGetDisplayNameOf
    Returns Names with GUIDs
  • Q178665 - SAMPLE RegView.exe Contains Shell
    Namespace Extension Example

21
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com