//
//  Microsoft Windows
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
//  File: shobjidl.idl
//
//  Contents: This interface definition contains shell objects that can be remoted
//


import "objidl.idl";
import "oleidl.idl";
import "oaidl.idl";
import "docobj.idl";
import "shtypes.idl";
import "servprov.idl";
import "comcat.idl";        // for IEnumGUID
import "propidl.idl";
import "prsht.idl";
import "msxml.idl";
import "wtypes.idl";
import "propsys.idl";
import "ObjectArray.idl";
import "StructuredQueryCondition.idl";

cpp_quote("#include <sherrors.h>")

cpp_quote("#ifndef SHSTDAPI")
cpp_quote("#if defined(_SHELL32_)")
cpp_quote("#define SHSTDAPI          STDAPI")
cpp_quote("#define SHSTDAPI_(type)   STDAPI_(type)")
cpp_quote("#else")
cpp_quote("#define SHSTDAPI          EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE")
cpp_quote("#define SHSTDAPI_(type)   EXTERN_C DECLSPEC_IMPORT type STDAPICALLTYPE")
cpp_quote("#endif")
cpp_quote("#endif // SHSTDAPI")

cpp_quote("")
cpp_quote("//===========================================================================")
cpp_quote("//")
cpp_quote("// IContextMenu interface")
cpp_quote("//")
cpp_quote("// [OverView]")
cpp_quote("//")
cpp_quote("//  The shell uses the IContextMenu interface in following three cases.")
cpp_quote("//")
cpp_quote("// case-1: The shell is loading context menu extensions.")
cpp_quote("//")
cpp_quote("//   When the user clicks the right mouse button on an item within the shell's")
cpp_quote("//  name space (i.g., file, directory, server, work-group, etc.), it creates")
cpp_quote("//  the default context menu for its type, then loads context menu extensions")
cpp_quote("//  that are registered for that type (and its base type) so that they can")
cpp_quote("//  add extra menu items. Those context menu extensions are registered at")
cpp_quote("//  HKCR\{ProgID}\shellex\ContextMenuHandlers.")
cpp_quote("//")
cpp_quote("// case-2: The shell is retrieving a context menu of sub-folders in extended")
cpp_quote("//   name-space.")
cpp_quote("//")
cpp_quote("//   When the explorer's name space is extended by name space extensions,")
cpp_quote("//  the shell calls their IShellFolder::GetUIObjectOf to get the IContextMenu")
cpp_quote("//  objects when it creates context menus for folders under those extended")
cpp_quote("//  name spaces.")
cpp_quote("//")
cpp_quote("// case-3: The shell is loading non-default drag and drop handler for directories.")
cpp_quote("//")
cpp_quote("//   When the user performed a non-default drag and drop onto one of file")
cpp_quote("//  system folders (i.e., directories), it loads shell extensions that are")
cpp_quote("//  registered at HKCR\{ProgID}\DragDropHandlers.")
cpp_quote("//")
cpp_quote("//")
cpp_quote("// [Member functions]")
cpp_quote("//")
cpp_quote("//")
cpp_quote("// IContextMenu::QueryContextMenu")
cpp_quote("//")
cpp_quote("//   This member function may insert one or more menuitems to the specified")
cpp_quote("//  menu (hmenu) at the specified location (indexMenu which is never be -1).")
cpp_quote("//  The IDs of those menuitem must be in the specified range (idCmdFirst and")
cpp_quote("//  idCmdLast). It returns the maximum menuitem ID offset (ushort) in the")
cpp_quote("//  'code' field (low word) of the scode.")
cpp_quote("//")
cpp_quote("//   The uFlags specify the context. It may have one or more of following")
cpp_quote("//  flags.")
cpp_quote("//")
cpp_quote("//  CMF_DEFAULTONLY: This flag is passed if the user is invoking the default")
cpp_quote("//   action (typically by double-clicking, case 1 and 2 only). Context menu")
cpp_quote("//   extensions (case 1) should not add any menu items, and returns S_OK.")
cpp_quote("//")
cpp_quote("//  CMF_VERBSONLY: The explorer passes this flag if it is constructing")
cpp_quote("//   a context menu for a short-cut object (case 1 and case 2 only). If this")
cpp_quote("//   flag is passed, it should not add any menu-items that is not appropriate")
cpp_quote("//   from a short-cut.")
cpp_quote("//    A good example is the Delete menuitem, which confuses the user")
cpp_quote("//   because it is not clear whether it deletes the link source item or the")
cpp_quote("//   link itself.")
cpp_quote("//")
cpp_quote("//  CMF_EXPLORER: The explorer passes this flag if it has the left-side pane")
cpp_quote("//   (case 1 and 2 only). Context menu extensions should ignore this flag.")
cpp_quote("//")
cpp_quote("//   High word (16-bit) are reserved for context specific communications")
cpp_quote("//  and the rest of flags (13-bit) are reserved by the system.")
cpp_quote("//")
cpp_quote("//")
cpp_quote("// IContextMenu::InvokeCommand")
cpp_quote("//")
cpp_quote("//   This member is called when the user has selected one of menuitems that")
cpp_quote("//  are inserted by previous QueryContextMenu member. In this case, the")
cpp_quote("//  LOWORD(lpici->lpVerb) contains the menuitem ID offset (menuitem ID -")
cpp_quote("//  idCmdFirst).")
cpp_quote("//")
cpp_quote("//   This member function may also be called programmatically. In such a case,")
cpp_quote("//  lpici->lpVerb specifies the canonical name of the command to be invoked,")
cpp_quote("//  which is typically retrieved by GetCommandString member previously.")
cpp_quote("//")
cpp_quote("//  Parameters in lpci:")
cpp_quote("//    cbSize -- Specifies the size of this structure (sizeof(*lpci))")
cpp_quote("//    hwnd   -- Specifies the owner window for any message/dialog box.")
cpp_quote("//    fMask  -- Specifies whether or not dwHotkey/hIcon paramter is valid.")
cpp_quote("//    lpVerb -- Specifies the command to be invoked.")
cpp_quote("//    lpParameters -- Parameters (optional)")
cpp_quote("//    lpDirectory  -- Working directory (optional)")
cpp_quote("//    nShow -- Specifies the flag to be passed to ShowWindow (SW_*).")
cpp_quote("//    dwHotKey -- Hot key to be assigned to the app after invoked (optional).")
cpp_quote("//    hIcon -- Specifies the icon (optional).")
cpp_quote("//    hMonitor -- Specifies the default monitor (optional).")
cpp_quote("//")
cpp_quote("//")
cpp_quote("// IContextMenu::GetCommandString")
cpp_quote("//")
cpp_quote("//   This member function is called by the explorer either to get the")
cpp_quote("//  canonical (language independent) command name (uFlags == GCS_VERB) or")
cpp_quote("//  the help text ((uFlags & GCS_HELPTEXT) != 0) for the specified command.")
cpp_quote("//  The retrieved canonical string may be passed to its InvokeCommand")
cpp_quote("//  member function to invoke a command programmatically. The explorer")
cpp_quote("//  displays the help texts in its status bar; therefore, the length of")
cpp_quote("//  the help text should be reasonably short (<40 characters).")
cpp_quote("//")
cpp_quote("//  Parameters:")
cpp_quote("//   idCmd -- Specifies menuitem ID offset (from idCmdFirst)")
cpp_quote("//   uFlags -- Either GCS_VERB or GCS_HELPTEXT")
cpp_quote("//   pwReserved -- Reserved (must pass NULL when calling, must ignore when called)")
cpp_quote("//   pszName -- Specifies the string buffer.")
cpp_quote("//   cchMax -- Specifies the size of the string buffer.")
cpp_quote("//")
cpp_quote("//===========================================================================")
cpp_quote("")
cpp_quote("// QueryContextMenu uFlags")
cpp_quote("#define CMF_NORMAL              0x00000000")
cpp_quote("#define CMF_DEFAULTONLY         0x00000001")
cpp_quote("#define CMF_VERBSONLY           0x00000002")
cpp_quote("#define CMF_EXPLORE             0x00000004")
cpp_quote("#define CMF_NOVERBS             0x00000008")
cpp_quote("#define CMF_CANRENAME           0x00000010")
cpp_quote("#define CMF_NODEFAULT           0x00000020")
cpp_quote("#if (NTDDI_VERSION < NTDDI_VISTA)")
cpp_quote("#define CMF_INCLUDESTATIC       0x00000040")      // deprecated - do not use
cpp_quote("#endif")
cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define CMF_ITEMMENU            0x00000080")
cpp_quote("#endif")
cpp_quote("#define CMF_EXTENDEDVERBS       0x00000100")      // rarely used verbs
cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define CMF_DISABLEDVERBS       0x00000200")
cpp_quote("#endif")
cpp_quote("#define CMF_ASYNCVERBSTATE      0x00000400")      // the verb state can be evaluated asynchronously
cpp_quote("#define CMF_OPTIMIZEFORINVOKE   0x00000800")      // Context menu handlers that do not support invoking verb via canonical verb names (lpVerb)
                                                             // can avoid the work in their QueryContextMenu implementation when this flag is present
cpp_quote("#define CMF_SYNCCASCADEMENU     0x00001000")      // Populate the cascade menu synchronously
cpp_quote("#define CMF_DONOTPICKDEFAULT    0x00002000")      // Tell the context menu to not pick default verb if none is explicitly specified
cpp_quote("#define CMF_RESERVED            0xffff0000")      // View specific
cpp_quote("")
cpp_quote("// GetCommandString uFlags")
cpp_quote("#define GCS_VERBA        0x00000000     // canonical verb")
cpp_quote("#define GCS_HELPTEXTA    0x00000001     // help text (for status bar)")
cpp_quote("#define GCS_VALIDATEA    0x00000002     // validate command exists")
cpp_quote("#define GCS_VERBW        0x00000004     // canonical verb (unicode)")
cpp_quote("#define GCS_HELPTEXTW    0x00000005     // help text (unicode version)")
cpp_quote("#define GCS_VALIDATEW    0x00000006     // validate command exists (unicode)")
cpp_quote("#define GCS_VERBICONW    0x00000014     // icon string (unicode)")
cpp_quote("#define GCS_UNICODE      0x00000004     // for bit testing - Unicode string")
cpp_quote("")
cpp_quote("#ifdef UNICODE")
cpp_quote("#define GCS_VERB        GCS_VERBW")
cpp_quote("#define GCS_HELPTEXT    GCS_HELPTEXTW")
cpp_quote("#define GCS_VALIDATE    GCS_VALIDATEW")
cpp_quote("#else")
cpp_quote("#define GCS_VERB        GCS_VERBA")
cpp_quote("#define GCS_HELPTEXT    GCS_HELPTEXTA")
cpp_quote("#define GCS_VALIDATE    GCS_VALIDATEA")
cpp_quote("#endif")
cpp_quote("")
cpp_quote("#define CMDSTR_NEWFOLDERA   \"NewFolder\"")
cpp_quote("#define CMDSTR_VIEWLISTA    \"ViewList\"")
cpp_quote("#define CMDSTR_VIEWDETAILSA \"ViewDetails\"")
cpp_quote("#define CMDSTR_NEWFOLDERW   L\"NewFolder\"")
cpp_quote("#define CMDSTR_VIEWLISTW    L\"ViewList\"")
cpp_quote("#define CMDSTR_VIEWDETAILSW L\"ViewDetails\"")
cpp_quote("")
cpp_quote("#ifdef UNICODE")
cpp_quote("#define CMDSTR_NEWFOLDER    CMDSTR_NEWFOLDERW")
cpp_quote("#define CMDSTR_VIEWLIST     CMDSTR_VIEWLISTW")
cpp_quote("#define CMDSTR_VIEWDETAILS  CMDSTR_VIEWDETAILSW")
cpp_quote("#else")
cpp_quote("#define CMDSTR_NEWFOLDER    CMDSTR_NEWFOLDERA")
cpp_quote("#define CMDSTR_VIEWLIST     CMDSTR_VIEWLISTA")
cpp_quote("#define CMDSTR_VIEWDETAILS  CMDSTR_VIEWDETAILSA")
cpp_quote("#endif")
cpp_quote("")
cpp_quote("#define CMIC_MASK_HOTKEY        SEE_MASK_HOTKEY")
cpp_quote("#define CMIC_MASK_ICON          SEE_MASK_ICON") //  not used
cpp_quote("#define CMIC_MASK_FLAG_NO_UI    SEE_MASK_FLAG_NO_UI")
cpp_quote("#define CMIC_MASK_UNICODE       SEE_MASK_UNICODE")
cpp_quote("#define CMIC_MASK_NO_CONSOLE    SEE_MASK_NO_CONSOLE")
cpp_quote("#if (NTDDI_VERSION < NTDDI_VISTA)")
cpp_quote("#define CMIC_MASK_HASLINKNAME   SEE_MASK_HASLINKNAME")
cpp_quote("#define CMIC_MASK_HASTITLE      SEE_MASK_HASTITLE")
cpp_quote("#endif  // NTDDI_VISTA")
cpp_quote("#define CMIC_MASK_FLAG_SEP_VDM  SEE_MASK_FLAG_SEPVDM")
cpp_quote("#define CMIC_MASK_ASYNCOK       SEE_MASK_ASYNCOK")
cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define CMIC_MASK_NOASYNC       SEE_MASK_NOASYNC")
cpp_quote("#endif")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE501)")
cpp_quote("#define CMIC_MASK_SHIFT_DOWN    0x10000000")
cpp_quote("#define CMIC_MASK_CONTROL_DOWN  0x40000000")
cpp_quote("#endif  // _WIN32_IE_IE501")
cpp_quote("#if (_WIN32_IE >= 0x0560)")
cpp_quote("#define CMIC_MASK_FLAG_LOG_USAGE SEE_MASK_FLAG_LOG_USAGE")
cpp_quote("#define CMIC_MASK_NOZONECHECKS  SEE_MASK_NOZONECHECKS")
cpp_quote("#endif // (_WIN32_IE >= 0x560)")
cpp_quote("")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE40)")
cpp_quote("#define CMIC_MASK_PTINVOKE      0x20000000")
cpp_quote("#endif  // _WIN32_IE_IE40")
cpp_quote("")
cpp_quote("#include <pshpack8.h>")
cpp_quote("")

//NOTE: When SEE_MASK_HMONITOR is set, hIcon is treated as hMonitor
typedef struct _CMINVOKECOMMANDINFO
{
    DWORD cbSize;        // sizeof(CMINVOKECOMMANDINFO)
    DWORD fMask;         // any combination of CMIC_MASK_*
    HWND hwnd;           // might be NULL (indicating no owner window)
    LPCSTR lpVerb;       // either a string or MAKEINTRESOURCE(idOffset)
    LPCSTR lpParameters; // might be NULL (indicating no parameter)
    LPCSTR lpDirectory;  // might be NULL (indicating no specific directory)
    int nShow;           // one of SW_ values for ShowWindow() API
    DWORD dwHotKey;
    HANDLE hIcon;
} CMINVOKECOMMANDINFO;

typedef CMINVOKECOMMANDINFO *LPCMINVOKECOMMANDINFO;
typedef const CMINVOKECOMMANDINFO *PCCMINVOKECOMMANDINFO;

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE40)")
typedef struct _CMINVOKECOMMANDINFOEX
{
    DWORD cbSize;            // must be sizeof(CMINVOKECOMMANDINFOEX)
    DWORD fMask;             // any combination of CMIC_MASK_*
    HWND hwnd;               // might be NULL (indicating no owner window)
    LPCSTR lpVerb;           // either a string or MAKEINTRESOURCE(idOffset)
    LPCSTR lpParameters;     // might be NULL (indicating no parameter)
    LPCSTR lpDirectory;      // might be NULL (indicating no specific directory)
    int nShow;               // one of SW_ values for ShowWindow() API
    DWORD dwHotKey;
    HANDLE hIcon;
    LPCSTR lpTitle;         // For CreateProcess-StartupInfo.lpTitle
    LPCWSTR lpVerbW;        // Unicode verb (for those who can use it)
    LPCWSTR lpParametersW;  // Unicode parameters (for those who can use it)
    LPCWSTR lpDirectoryW;   // Unicode directory (for those who can use it)
    LPCWSTR lpTitleW;       // Unicode title (for those who can use it)
    POINT   ptInvoke;       // Point where it's invoked
} CMINVOKECOMMANDINFOEX;
cpp_quote("#else")
cpp_quote("typedef struct _PRE_IE4_CMINVOKECOMMANDINFOEX")
cpp_quote("{")
cpp_quote("    DWORD cbSize;            // must be sizeof(CMINVOKECOMMANDINFOEX)")
cpp_quote("    DWORD fMask;             // any combination of CMIC_MASK_*")
cpp_quote("    HWND hwnd;               // might be NULL (indicating no owner window)")
cpp_quote("    LPCSTR lpVerb;           // either a string or MAKEINTRESOURCE(idOffset)")
cpp_quote("    LPCSTR lpParameters;     // might be NULL (indicating no parameter)")
cpp_quote("    LPCSTR lpDirectory;      // might be NULL (indicating no specific directory)")
cpp_quote("    int nShow;               // one of SW_ values for ShowWindow() API")
cpp_quote("    DWORD dwHotKey;")
cpp_quote("    HANDLE hIcon;")
cpp_quote("    LPCSTR lpTitle;         // For CreateProcess-StartupInfo.lpTitle")
cpp_quote("    LPCWSTR lpVerbW;        // Unicode verb (for those who can use it)")
cpp_quote("    LPCWSTR lpParametersW;  // Unicode parameters (for those who can use it)")
cpp_quote("    LPCWSTR lpDirectoryW;   // Unicode directory (for those who can use it)")
cpp_quote("    LPCWSTR lpTitleW;       // Unicode title (for those who can use it)")
cpp_quote("} CMINVOKECOMMANDINFOEX;")
cpp_quote("#endif   // _WIN32_IE_IE40")

typedef CMINVOKECOMMANDINFOEX *LPCMINVOKECOMMANDINFOEX;
typedef const CMINVOKECOMMANDINFOEX *PCCMINVOKECOMMANDINFOEX;

cpp_quote("#include <poppack.h>")

// IContextMenu
[
    local,
    uuid(000214e4-0000-0000-c000-000000000046), // IID_IContextMenu
    pointer_default(unique),
]
interface IContextMenu : IUnknown
{
    HRESULT QueryContextMenu(
        [in, annotation("__in")] HMENU hmenu,
        [in, annotation("__in")] UINT indexMenu,
        [in, annotation("__in")] UINT idCmdFirst,
        [in, annotation("__in")] UINT idCmdLast,
        [in, annotation("__in")] UINT uFlags);

    HRESULT InvokeCommand([in, annotation("__in")] CMINVOKECOMMANDINFO *pici);

    HRESULT GetCommandString(
        [in, annotation("__in")] UINT_PTR idCmd,
        [in, annotation("__in")] UINT uType,
        [in, annotation("__reserved")] UINT * pReserved,
        [out, annotation("__out_awcount(!(uType & GCS_UNICODE), cchMax)")] LPSTR pszName,
        [in, annotation("__in")] UINT cchMax);
}

typedef IContextMenu *LPCONTEXTMENU;

// IContextMenu2
[
    local,
    uuid(000214f4-0000-0000-c000-000000000046), // IID_IContextMenu2
    pointer_default(unique),
]
interface IContextMenu2 : IContextMenu
{
    HRESULT HandleMenuMsg(
        [in, annotation("__in")] UINT uMsg,
        [in, annotation("__in")] WPARAM wParam,
        [in, annotation("__in")] LPARAM lParam);
}

typedef IContextMenu2 * LPCONTEXTMENU2;

// IContextMenu3
[
    local,
    uuid(BCFCE0A0-EC17-11d0-8D10-00A0C90F2719), // IID_IContextMenu3
    pointer_default(unique),
]
interface IContextMenu3 : IContextMenu2
{
    HRESULT HandleMenuMsg2(
        [in, annotation("__in")] UINT uMsg,
        [in, annotation("__in")] WPARAM wParam,
        [in, annotation("__in")] LPARAM lParam,
        [out, annotation("__out_opt")] LRESULT* plResult);
}

typedef IContextMenu3 * LPCONTEXTMENU3;

// IExecuteCommand
[
    uuid(7F9185B0-CB92-43c5-80A9-92277A4F7B54),
    object,
    pointer_default(unique)
]
interface IExecuteCommand : IUnknown
{
    // key state values MK_CONTROL & MK_SHIFT
    HRESULT SetKeyState([in] DWORD grfKeyState);

    // for context menu invokes this comes from CMINVOKECOMMANDINFO.lpParameters
    HRESULT SetParameters([in, string] LPCWSTR pszParameters);

    // default Position = center of default monitor
    HRESULT SetPosition([in] POINT pt);

    // default = SW_NORMAL
    HRESULT SetShowWindow([in] int nShow);

    // default = FALSE
    HRESULT SetNoShowUI([in] BOOL fNoShowUI);

    // default Directory = GetCurrentDirectory()
    HRESULT SetDirectory([in, string] LPCWSTR pszDirectory);

    // this is where the work happens!
    HRESULT Execute();
};

// IPersistFolder
[
    object,
    uuid(000214EA-0000-0000-C000-000000000046),  // IID_IPersistFolder
    pointer_default(unique),
]
interface IPersistFolder : IPersist
{
    // IShellFolder::BindToObject when it is initializing a shell folder object.")
    // called when the explorer is initializing a shell folder object.
    // pidl -- Specifies the absolute location of the folder
    HRESULT Initialize([in] PCIDLIST_ABSOLUTE pidl);
}

typedef IPersistFolder *LPPERSISTFOLDER;

cpp_quote("#if (_WIN32_IE >= 0x0400)")

// IRunnableTask
//
//  object that implement IRunnable must be *free threaded*. It is used for creating
//  objects to be asynchronously executed on a background thread by a task
//  scheduler.  The task scheduler is free to call any method on the
//  IRunnable task on any thread as it sees fit (i.e. a task scheduler is not
//  guaranteed to only have a single background worker thread, nor is it
//  restricted to not call the IRunnableTask methods on the original queuing
//  thread).
//
// Note:
//
//  The Run() member is called by the scheduler to start the task executing.
//  If the task supports being suspended and has been signalled to do so
//  (via receiving a call from the scheduler to Suspend()), it should return
//  from Run() with a value of E_PENDING.  The task will then be held and
//  resumed by the scheduler at a later time by receiving a call to Resume()
//  (assuming it's not destroyed for some reason first).

// IRunnableTask convenient state values
cpp_quote("#define IRTIR_TASK_NOT_RUNNING   0")
cpp_quote("#define IRTIR_TASK_RUNNING       1")
cpp_quote("#define IRTIR_TASK_SUSPENDED     2")
cpp_quote("#define IRTIR_TASK_PENDING       3")
cpp_quote("#define IRTIR_TASK_FINISHED      4")

[
    uuid(85788d00-6807-11d0-b810-00c04fd706ec), // IID_IRunnableTask
    object,
    local
]
interface IRunnableTask : IUnknown
{
    HRESULT Run();

    HRESULT Kill([in, annotation("__in")] BOOL bWait);

    HRESULT Suspend();

    HRESULT Resume();

    ULONG IsRunning();
}

// IShellTaskScheduler::AddTask()/RemoveTasks()/CountTasks() default arguments
cpp_quote("#define TOID_NULL                    GUID_NULL")
cpp_quote("#define ITSAT_DEFAULT_LPARAM         ((DWORD_PTR)-1)")

// IShellTaskScheduler::AddTask() priorities
// This depends on the cooperation of tasks currently under execution.
// New tasks will be inserted in the queue in priority order. If a task
// of a low priority is currently under execution when a higher priority
// task is added, the scheduler will attempt to suspend the task
// currently under execution. It will be resumed when the other tasks
// have been completed.
cpp_quote("#define ITSAT_DEFAULT_PRIORITY       0x10000000")
cpp_quote("#define ITSAT_MAX_PRIORITY           0x7fffffff")
cpp_quote("#define ITSAT_MIN_PRIORITY           0x00000000")

// IShellTaskScheduler::Status() flags
cpp_quote("#define ITSSFLAG_COMPLETE_ON_DESTROY 0x0000 // wait for the current task to complete before deleting the scheduler")
cpp_quote("#define ITSSFLAG_KILL_ON_DESTROY     0x0001 // kill the current task (if there is one) when the task scheduler is deleted")
cpp_quote("#define ITSSFLAG_FLAGS_MASK          0x0003")

// IShellTaskScheduler::Status() timeouts
cpp_quote("#define ITSS_THREAD_DESTROY_DEFAULT_TIMEOUT  (10*1000)       // default milliseconds until a sleeping worker thread is released")
cpp_quote("#define ITSS_THREAD_TERMINATE_TIMEOUT        (INFINITE)      // set sleeping worker threads to never be released")
cpp_quote("#define ITSS_THREAD_TIMEOUT_NO_CHANGE        (INFINITE - 1)  // no change to the thread timeout")

// interface for interacting with and controlling a task scheduler.
// This interface is free-threaded (since queued tasks can
// interact with the scheduler as well as the main execution
// thread on which the task scheduler was created).
[
    uuid(6CCB7BE0-6807-11d0-B810-00C04FD706EC),
    object,
    local
]
interface IShellTaskScheduler : IUnknown
{
    // Adds Tasks to the scheduler's background queue. The TASKOWNERID allow particular types
    // of tasks to be grouped so that they can be counted or removed. The lParam allows the task
    // to be associated with a particular item (for example an item in a listview).  Thus, all
    // tasks owned by a particular item can be accessed by passing a non default value for this
    // parameter (i.e. to RemoveTasks()).
    HRESULT AddTask(
        [in, annotation("__in")] IRunnableTask *prt,
        [in, annotation("__in")] REFTASKOWNERID rtoid,
        [in, annotation("__in")] DWORD_PTR lParam,
        [in, annotation("__in")] DWORD dwPriority);

    // Removes tasks from the scheduler's queue. These can be sepcified in terms of their TASKOWNERID
    // or their LPARAM, or both, or neither (TOID_NULL && ITSAT_DEFAULT_LPARAM results in all tasks being
    // removed). If a task that matches is currently running and ITaskScheduler::Status() has been
    // passeed ITSSFLAG_KILL_ON_DESTROY then the scheduler will attempt to kill the current task. The
    // fWaitIfRunning parameter is then passed to IRunnableTask::Kill().
    HRESULT RemoveTasks(
        [in, annotation("__in")] REFTASKOWNERID rtoid,
        [in, annotation("__in")] DWORD_PTR lParam,
        [in, annotation("__in")] BOOL bWaitIfRunning);

    // returns the count of tasks in the queue depending upon the TASKOWNERID and the LPARAM passed.
    // pass TOID_NULL to count all tasks in the queue
    UINT CountTasks([in, annotation("__in")] REFTASKOWNERID rtoid);

    // This sets the ReleaseStatus for the current task and the background thread timeout. When
    // ITaskScheduler::RemoveTasks() is called and there is a task currently running that matches
    // ITSSFLAG_COMPLETE_ON_DESTROY will cause TRUE to be passed to the task's IRunnableTask::Kill().
    // The dwThreadTimeout parameter if not set to the default will cause the background thread to
    // die if no new tasks have been added to the queue in the timeout period. The Thread will be
    // recreated when the next new task is added.
    HRESULT Status(
        [in, annotation("__in")] DWORD dwReleaseStatus,
        [in, annotation("__in")] DWORD dwThreadTimeout);
};

cpp_quote("#define SID_ShellTaskScheduler IID_IShellTaskScheduler")


[
    object,
    uuid("C7B236CE-EE80-11D0-985F-006008059382"),
    pointer_default(unique),
    local
]
interface IQueryCodePage : IUnknown
{
    HRESULT GetCodePage([out, annotation("__out")] UINT *puiCodePage);
    HRESULT SetCodePage([in, annotation("__in")] UINT uiCodePage);
} ;

// IPersistFolder2
[
    object,
    uuid(1AC3D9F0-175C-11d1-95BE-00609797EA4F),  // IID_IPersistFolder2
    pointer_default(unique),
]
interface IPersistFolder2 : IPersistFolder
{
    HRESULT GetCurFolder([out] PIDLIST_ABSOLUTE *ppidl);
}

cpp_quote("#endif")

cpp_quote("#if (_WIN32_IE >= 0x0500)")

cpp_quote("#define CSIDL_FLAG_PFTI_TRACKTARGET CSIDL_FLAG_DONT_VERIFY")

// DESCRIPTION: PERSIST_FOLDER_TARGET_INFO
//    This stucture is used for Folder Shortcuts which allow the shell to
// have a file system folder act like another area in the name space.
// One of pidlTargetFolder, szTargetParsingName, or csidl needs to
// specify the destination name space.
//
// pidlTargetFolder: This is a full pidl to the target folder.  Can be NULL in the IPersistFolder3::InitializeEx()
//                   call but not in the GetFolderTargetInfo() return structure.
// szTargetParsingName: Empty string if not specified. Ortherwise, it is the parsible name
//                       to the target.  This name can be parsed by IShellFolder::
//                       ParsedName() from the desktop.
// szNetworkProvider: Can be an empty string.  If not empty, it specifies the type of network
//                    provider that will be used when binding to the target.  This is used
//                    for performance optimizations for the WNet APIs.
// dwAttributes: -1 if not known.  These are the SFGAO_ flags for IShellFolder::GetAttributesOf()
// csidl: This is -1 if it's not used.  This can be used instead of pidlTargetFolder or
//        szTargetParsingName to indicate the TargetFolder.  See the list of CSIDL_ folders
//        below.  CSIDL_FLAG_PFTI_TRACKTARGET means that the IShellFolder's target folder
//        should change if the user changes the target of the underlying CSIDL value.
//        You can also pass CSIDL_FLAG_CREATE to indicate that the target folder
//        should be created if it does not exist.  No other CSIDL_FLAG_* values are supported.

cpp_quote("#include <pshpack8.h>")

#ifndef MAX_PATH
#define MAX_PATH 260
#endif

typedef struct _PERSIST_FOLDER_TARGET_INFO
{
    PIDLIST_ABSOLUTE pidlTargetFolder;              // pidl for the folder we want to intiailize
    WCHAR            szTargetParsingName[MAX_PATH]; // optional parsing name for the target
    WCHAR            szNetworkProvider[MAX_PATH];   // optional network provider
    DWORD            dwAttributes;                  // optional FILE_ATTRIBUTES_ flags (-1 if not used)
    int              csidl;                         // optional folder index (SHGetFolderPath()) -1 if not used
} PERSIST_FOLDER_TARGET_INFO;

cpp_quote("#include <poppack.h>")


// DESCRIPTION: IPersistFolder3
//    This interface is implemented by an IShellFolder object that wants non-default
// handling of Folder Shortcuts.  In general, shell name space extensions should use
// pidlRoot (the alias pidl) as their location in the name space and pass it to public
// APIs, such as ShellExecute().  The one exception is that pidlTarget should be used
// when sending ChangeNotifies or registering to listen for change notifies
// (see SFVM_GETNOTIFY).
//
// InitializeEx: This method initializes an IShellFolder and specifies where
//               it is rooted in the name space.
//      pbc: May be NULL.
//      pidlRoot: This is the same parameter as IPersistFolder::Initialize(). Caller allocates
//                and frees this parameter.
//      ppfti: May be NULL, in which case this is the same as a call to IPersistFolder::Initialize().
//             Otherwise this is a Folder Shortcut and this structure specifies the target
//             folder and it's attributes.
// GetFolderTargetInfo: This is used by the caller to find information about
//             the folder shortcut.  This structure may not be initialized by the caller,
//             so the callee needs to initialize every member.  The callee allocates
//             pidlTargetFolder and the caller will free it.  Filling in pidlTargetFolder is
//             ALWAYS required.
[
    object,
    uuid(CEF04FDF-FE72-11d2-87A5-00C04F6837CF),  // IID_IPersistFolder3
    pointer_default(unique),
]
interface IPersistFolder3 : IPersistFolder2
{
    HRESULT InitializeEx(
        [in, unique] IBindCtx *pbc,
        [in] PCIDLIST_ABSOLUTE pidlRoot,
        [in, unique] const PERSIST_FOLDER_TARGET_INFO *ppfti);

    HRESULT GetFolderTargetInfo([out] PERSIST_FOLDER_TARGET_INFO *ppfti);
}

cpp_quote("#endif")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP) || (_WIN32_IE >= _WIN32_IE_IE70)")

[
    object,
    uuid(1079acfc-29bd-11d3-8e0d-00c04f6837d5),  // IID_IPersistIDList
    pointer_default(unique),
]
interface IPersistIDList : IPersist
{
    // sets or gets a fully qualifed idlist for an object
    HRESULT SetIDList([in] PCIDLIST_ABSOLUTE pidl);

    HRESULT GetIDList([out] PIDLIST_ABSOLUTE *ppidl);
}

cpp_quote("#endif  // NTDDI_WINXP|| (_WIN32_IE >= _WIN32_IE_IE70)")

[
    uuid(000214F2-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface IEnumIDList : IUnknown
{
    [local] HRESULT Next(
        [in, annotation("__in")] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched), annotation("__out_ecount_part(celt, *pceltFetched)")] PITEMID_CHILD *rgelt,
        [out, annotation("__out_opt __deref_out_range(0, celt)")] ULONG *pceltFetched);

    [call_as(Next)] HRESULT RemoteNext([in] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched)] PITEMID_CHILD *rgelt,
        [out] ULONG* pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumIDList **ppenum);
}

typedef IEnumIDList *LPENUMIDLIST;

[
    uuid(d0191542-7954-4908-bc06-b2360bbe45ba),
    object,
    pointer_default(unique)
]
interface IEnumFullIDList : IUnknown
{
    [local]
    HRESULT Next(
        [in, annotation("__in")] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched), annotation("__out_ecount_part(celt, *pceltFetched)")] PIDLIST_ABSOLUTE *rgelt,
        [out, annotation("__out_opt __deref_out_range(0, celt)")] ULONG *pceltFetched);

    [call_as(Next)]
    HRESULT RemoteNext(
        [in] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched)] PIDLIST_ABSOLUTE *rgelt,
        [out] ULONG *pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumFullIDList **ppenum);
}

// IShellFolder::GetDisplayNameOf/SetNameOf uFlags
[v1_enum] enum _SHGDNF
{
    SHGDN_NORMAL             = 0x0000,  // default (display purpose)
    SHGDN_INFOLDER           = 0x0001,  // displayed under a folder (relative)
    SHGDN_FOREDITING         = 0x1000,  // for in-place editing
    SHGDN_FORADDRESSBAR      = 0x4000,  // UI friendly parsing name (remove ugly stuff)
    SHGDN_FORPARSING         = 0x8000,  // parsing name for ParseDisplayName()
};
typedef DWORD SHGDNF;

// IShellFolder::EnumObjects grfFlags bits
[v1_enum] enum _SHCONTF
{
    SHCONTF_CHECKING_FOR_CHILDREN   = 0x00010,   // hint that client is checking if (what) child items the folder contains - not all details (e.g. short file name) are needed
    SHCONTF_FOLDERS                 = 0x00020,   // only want folders enumerated (SFGAO_FOLDER)
    SHCONTF_NONFOLDERS              = 0x00040,   // include non folders (items without SFGAO_FOLDER)
    SHCONTF_INCLUDEHIDDEN           = 0x00080,   // show items normally hidden (items with SFGAO_HIDDEN)
    SHCONTF_INIT_ON_FIRST_NEXT      = 0x00100,   // DEFUNCT - this is always assumed
    SHCONTF_NETPRINTERSRCH          = 0x00200,   // hint that client is looking for printers
    SHCONTF_SHAREABLE               = 0x00400,   // hint that client is looking sharable resources (local drives or hidden root shares)
    SHCONTF_STORAGE                 = 0x00800,   // include all items with accessible storage and their ancestors including hidden items
    SHCONTF_NAVIGATION_ENUM         = 0x01000,   // mark child folders to indicate that they should provide a "navigation" enumeration by default
    SHCONTF_FASTITEMS               = 0x02000,   // hint that client is only interested in items that can be enumerated quickly
    SHCONTF_FLATLIST                = 0x04000,   // enumerate items as flat list even if folder is stacked
    SHCONTF_ENABLE_ASYNC            = 0x08000,   // inform enumerator that client is listening for change notifications so enumerator does not need to be complete, items can be reported via change notifications
    SHCONTF_INCLUDESUPERHIDDEN      = 0x10000,   // show system items that are hidden
};
typedef DWORD SHCONTF;

// IShellFolder::CompareIDs lParam flags
// *these should only be used if the folder supports IShellFolder2*
//
// SHCIDS_ALLFIELDS
//
// only be used in conjunction with SHCIDS_CANONCALONLY or column 0.
// This flag requests that the folder test for *pidl identity*, that is
// “are these pidls logically the same”. This implies that cached fields
// in the pidl that would distinguish them should be tested.
// Without this flag, you are comparing the *object* s the pidls refer to.
//
// SHCIDS_CANONICALONLY
//
// This indicates that the sort should be *the most efficient sort possible*, the implication
// being that the result will not be displayed to the UI: the SHCIDS_COLUMNMASK portion
// of the lParam can be ignored. (Before we had SHCIDS_CANONICALONLY
// we assumed column 0 was the "efficient" sort column.)
//
//

cpp_quote("#define SHCIDS_ALLFIELDS        0x80000000L")
cpp_quote("#define SHCIDS_CANONICALONLY    0x10000000L")
cpp_quote("#define SHCIDS_BITMASK          0xFFFF0000L")
cpp_quote("#define SHCIDS_COLUMNMASK       0x0000FFFFL")

// IShellFolder::GetAttributesOf flags
// SFGAO_CANLINK: If this bit is set on an item in the shell folder, a
//            'Create Shortcut' menu item will be added to the File
//            menu and context menus for the item.  If the user selects
//            that command, your IContextMenu::InvokeCommand() will be called
//            with 'link'.
//                 That flag will also be used to determine if 'Create Shortcut'
//            should be added when the item in your folder is dragged to another
//            folder.
cpp_quote("#define SFGAO_CANCOPY           DROPEFFECT_COPY // Objects can be copied    (0x1)")
cpp_quote("#define SFGAO_CANMOVE           DROPEFFECT_MOVE // Objects can be moved     (0x2)")
cpp_quote("#define SFGAO_CANLINK           DROPEFFECT_LINK // Objects can be linked    (0x4)")
cpp_quote("#define SFGAO_STORAGE           0x00000008L     // supports BindToObject(IID_IStorage)")
cpp_quote("#define SFGAO_CANRENAME         0x00000010L     // Objects can be renamed")
cpp_quote("#define SFGAO_CANDELETE         0x00000020L     // Objects can be deleted")
cpp_quote("#define SFGAO_HASPROPSHEET      0x00000040L     // Objects have property sheets")
//         unused                          0x00000080
cpp_quote("#define SFGAO_DROPTARGET        0x00000100L     // Objects are drop target")
cpp_quote("#define SFGAO_CAPABILITYMASK    0x00000177L")
//         unused                          0x00000200
//         unused                          0x00000400
//         unused                          0x00000800
cpp_quote("#define SFGAO_SYSTEM            0x00001000L     // System object")
cpp_quote("#define SFGAO_ENCRYPTED         0x00002000L     // Object is encrypted (use alt color)")
cpp_quote("#define SFGAO_ISSLOW            0x00004000L     // 'Slow' object")
cpp_quote("#define SFGAO_GHOSTED           0x00008000L     // Ghosted icon")
cpp_quote("#define SFGAO_LINK              0x00010000L     // Shortcut (link)")
cpp_quote("#define SFGAO_SHARE             0x00020000L     // Shared")
cpp_quote("#define SFGAO_READONLY          0x00040000L     // Read-only")
cpp_quote("#define SFGAO_HIDDEN            0x00080000L     // Hidden object")
cpp_quote("#define SFGAO_DISPLAYATTRMASK   0x000FC000L")
cpp_quote("#define SFGAO_FILESYSANCESTOR   0x10000000L     // May contain children with SFGAO_FILESYSTEM")
cpp_quote("#define SFGAO_FOLDER            0x20000000L     // Support BindToObject(IID_IShellFolder)")
cpp_quote("#define SFGAO_FILESYSTEM        0x40000000L     // Is a win32 file system object (file/folder/root)")
cpp_quote("#define SFGAO_HASSUBFOLDER      0x80000000L     // May contain children with SFGAO_FOLDER (may be slow)")
cpp_quote("#define SFGAO_CONTENTSMASK      0x80000000L")
cpp_quote("#define SFGAO_VALIDATE          0x01000000L     // Invalidate cached information (may be slow)")
cpp_quote("#define SFGAO_REMOVABLE         0x02000000L     // Is this removeable media?")
cpp_quote("#define SFGAO_COMPRESSED        0x04000000L     // Object is compressed (use alt color)")
cpp_quote("#define SFGAO_BROWSABLE         0x08000000L     // Supports IShellFolder, but only implements CreateViewObject() (non-folder view)")
cpp_quote("#define SFGAO_NONENUMERATED     0x00100000L     // Is a non-enumerated object (should be hidden)")
cpp_quote("#define SFGAO_NEWCONTENT        0x00200000L     // Should show bold in explorer tree")
cpp_quote("#define SFGAO_CANMONIKER        0x00400000L     // Obsolete")
cpp_quote("#define SFGAO_HASSTORAGE        0x00400000L     // Obsolete")
cpp_quote("#define SFGAO_STREAM            0x00400000L     // Supports BindToObject(IID_IStream)")
cpp_quote("#define SFGAO_STORAGEANCESTOR   0x00800000L     // May contain children with SFGAO_STORAGE or SFGAO_STREAM")
cpp_quote("#define SFGAO_STORAGECAPMASK    0x70C50008L     // For determining storage capabilities, ie for open/save semantics")
cpp_quote("#define SFGAO_PKEYSFGAOMASK     0x81044000L     // Attributes that are masked out for PKEY_SFGAOFlags because they are considered to cause slow calculations or lack context (SFGAO_VALIDATE | SFGAO_ISSLOW | SFGAO_HASSUBFOLDER and others)")

typedef ULONG SFGAOF;

//      passed to ISF::BindToObject() via IBindCtx::RegisterObjectParam()
// * no interface support required on object param
// If this param is passed to CFolderShortcut, IShellLink::Resolve will be invoked on the shortcut
// during the bind operation. This will result in slowness for shortcuts pointing to network paths.
cpp_quote("#define STR_BIND_FORCE_FOLDER_SHORTCUT_RESOLVE   L\"Force Folder Shortcut Resolve\"")

//      passed to ISF::BindToObject() via IBindCtx::RegisterObjectParam()
// * no interface support required on object param
// If this param is passed to CFSFolder, CFSFolder::_CheckDriveRestriction will not check to see
// if the drive it is on is restricted by SHRestriction(REST_NOVIEWONDRIVE) when someone tries
// to CreateViewObject() on it. This is utilized when this folder is being used as a CD burning staging area
// folder, and is not meant to be restricted because of this policy being applied to the drive that
// the staging area folder happens to reside on. This policy is NOT a security policy, and thus this
// is not a security breach. This flag is only sent by the CD folder when creating the IShellFolder for
// the staging area part of the merged folder view, and thus this parameter's existence will not prevent
// the policy from being implemented correctly when the CD drive itself has the group policy applied to it.
cpp_quote("#define STR_AVOID_DRIVE_RESTRICTION_POLICY   L\"Avoid Drive Restriction Policy\"")

//      passed to ISF::BindToObject() via IBindCtx::RegisterObjectParam()
// * no interface support required on object param
// If this param is passed to CFSFolder, CFSFolder::_CheckDriveRestriction will not check to see
// if the drive it is on is restricted by SHRestriction(REST_NOVIEWONDRIVE) when someone tries
// to CreateViewObject() on it. This is utilized when this folder is being used as a CD burning staging area
// folder, and is not meant to be restricted because of this policy being applied to the drive that
// the staging area folder happens to reside on. This policy is NOT a security policy, and thus this
// is not a security breach. This flag is only sent by the CD folder when creating the IShellFolder for
// the staging area part of the merged folder view, and thus this parameter's existence will not prevent
// the policy from being implemented correctly when the CD drive itself has the group policy applied to it.
cpp_quote("#define STR_AVOID_DRIVE_RESTRICTION_POLICY   L\"Avoid Drive Restriction Policy\"")

//      passed to ISF::ParseDisplayName() or ISF::BindToObject() via IBindCtx::RegisterObjectParam()
// * IPersist must be supported by the ObjectParam
// the CLSID returned by IPersist::GetCLSID() should be skipped
// in the binding process. used to avoid loops or to allow delegation to
// base name space functionality. see SHSkipJunction()
cpp_quote("#define STR_SKIP_BINDING_CLSID      L\"Skip Binding CLSID\"")

//      passed to SHGetDesktopFolder()->ParseDisplayName() via IBindCtx::RegisterObjectParam()
// * no interface support required on object param
// instructing to prefer folder support for URLs.  specifically used by the common
// dialog to make it use the DAV NP when parsing http: URLs.
cpp_quote("#define STR_PARSE_PREFER_FOLDER_BROWSING     L\"Parse Prefer Folder Browsing\"")

//      passed to SHGetDesktopFolder()->ParseDisplayName() via IBindCtx::RegisterObjectParam()
// instructing to fail parsing relative paths.  only succeeds for fully qualified paths/urls.
// * no interface support required on object param
//
//      eg. even if "foo.txt" is a child of the desktop, it will still fail
//  but it will succeed for "C:\Documents and Settings\Username\Desktop\foo.txt"
cpp_quote("#define STR_DONT_PARSE_RELATIVE              L\"Don't Parse Relative\"")

//      passed to SHGetDesktopFolder()->ParseDisplayName() via IBindCtx::RegisterObjectParam()
// to try translate from a full file system pidl to a alias to that pidl, if available.
// * no interface support required on object param
//
//      eg.  if you pass the following path "C:\Documents and Settings\Username\Desktop\foo.txt"
// if TRANSLATE is SET result is: [foo.txt] (the alias for the desktop being an empty pidl)
// if TRANSLATE is NOT SET result is: [CLSID_MyComputer][c:\][Documents and Settings][Username][Desktop][foo.txt].
cpp_quote("#define STR_PARSE_TRANSLATE_ALIASES          L\"Parse Translate Aliases\"")

//      passed to SHGetDesktopFolder()->ParseDisplayName() via IBindCtx::RegisterObjectParam()
// to disable the cache of network resources when parsing a name.  The cache is still
// populated with the results of the parse, however we skip the initial query.
cpp_quote("#define STR_PARSE_SKIP_NET_CACHE             L\"Skip Net Resource Cache\"")

// * no interface support required on object param
// instructing to allow shell: parsing to non-SFGAO_FOLDER objects.
// Safe to set this for strings an end-user types, but do not set this in any binding
// path where untrusted callers control the contents of the string
cpp_quote("#define STR_PARSE_SHELL_PROTOCOL_TO_FILE_OBJECTS     L\"Parse Shell Protocol To File Objects\"")

cpp_quote("#if (_WIN32_IE >= 0x0700)")
//      passed to IPersistFolder3->Initialize() via IBindCtx::RegisterObjectParam()
// Instructs the folder to track the location of the CLSID.  Currently dbfolder uses this to track the pivot of the
// regitem folder that aggregates it.
cpp_quote("#define STR_TRACK_CLSID                      L\"Track the CLSID\"")

//      passed to IPersistHistory::LoadHistory() to enable loading the history from a stream
// for an internal navigaton.  An internal navigation is a navigation within the same view.
cpp_quote("#define STR_INTERNAL_NAVIGATE                L\"Internal Navigation\"")

//      used to passed parsed properties to IShellFolder::ParseDisplayName for a delegate namespace.
//  the namespace can use this instead of attempting to parse the name itself
cpp_quote("#define STR_PARSE_PROPERTYSTORE             L\"DelegateNamedProperties\"")

//      passed to IShellFolder::ParseDisplayName() via IBindCtx::RegisterObjectParam()
// instructing to not fail parsing filenames with invalid characters.
// Meaningful only in conjunction with STR_FILE_SYS_BIND_DATA
// * no interface support required on object param
cpp_quote("#define STR_NO_VALIDATE_FILENAME_CHARS      L\"NoValidateFilenameChars\"")

// passed to ISF::BindToObject via IBindCtx::RegisterObjectParam()
// registered object must either implement ICreateObject or ISafeCreateObject
cpp_quote("#define STR_BIND_DELEGATE_CREATE_OBJECT L\"Delegate Object Creation\"")

cpp_quote("#define STR_PARSE_ALLOW_INTERNET_SHELL_FOLDERS   L\"Allow binding to Internet shell folder handlers and negate STR_PARSE_PREFER_WEB_BROWSING\"")
cpp_quote("#define STR_PARSE_PREFER_WEB_BROWSING   L\"Do not bind to Internet shell folder handlers\"")

//      passed to SHGetDesktopFolder()->ParseDisplayName() via IBindCtx::RegisterObjectParam()
// Instructs folders that manipulate network paths to show the network diagnostics UI when they
// encounter diagnosable failures.  If diagnosis succeeds, then the folder will try to parse the
// path again.  If parsing fails even after diagnosis, an appropriate error value will be returned.
// * no interface support required on object param
cpp_quote("#define STR_PARSE_SHOW_NET_DIAGNOSTICS_UI  L\"Show network diagnostics UI\"")

// deprecated
cpp_quote("#define STR_PARSE_DONT_REQUIRE_VALIDATED_URLS  L\"Do not require validated URLs\"")

// This should be used when STR_PARSE_PREFER_FOLDER_BROWSING is included in the BindCtx
// and the client desires the Internet shell folder handlers to generate an IDList for any valid URL
// if a DAV-type folder cannot be created for the given URL.  Specifically used by the common dialog
// to support opening files on the internet.
// This does not ensure that the URL actually exists.  It only checks the syntax of the URL and
// that it has a registered protocol handler.
// * no interface support required on object param
cpp_quote("#define STR_INTERNETFOLDER_PARSE_ONLY_URLMON_BINDABLE  L\"Validate URL\"")

cpp_quote("#endif // _WIN32_IE >= 0x0700")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN7)")

// Passed to IShellFolder::ParseDisplayName along with STR_FILE_SYS_BIND_DATA. This forces simple 
// parsing while also probing for desktop.ini files along the path to get a localized name string 
// if there's any. The advantage is not probing for folders along the path. A folder might be a 
// server or a share, so it may be very expensive. On the other hand, desktop.inis are cached in 
// at least some locations, so it will be as cheap or cheaper than probling for folders attribs and 
// then probing for desktop.ini if hte folder is read only.
cpp_quote("#define STR_BIND_FOLDERS_READ_ONLY L\"Folders As Read Only\"")

// Passed to IShellFolder::ParseDisplayName with an FOLDER_ENUM_MODE value to control
// the enumeration mode of the parsed item.  The FOLDER_ENUM_MODE is passed in the bind
// context via an object that implements IObjectWithFolderEnumMode.
//
// Items with different enumeration modes compare canonically (SHCIDS_CANONICALONLY) different
// because they enumerate different sets of items.
//
// If an item doesn't support the enumeration mode value (because it isn't a folder or it doesn't
// provide the enumeration mode) then it is created in the default enumeration mode.
cpp_quote("#define STR_BIND_FOLDER_ENUM_MODE L\"Folder Enum Mode\"")

typedef [v1_enum] enum FOLDER_ENUM_MODE
{
    FEM_VIEWRESULT    = 0, // main enumeration mode. default enumeration for a folder view, etc.
    FEM_NAVIGATION    = 1, // alternate enumeration mode for navigating folder's content. default enumeration for a navigation pane, etc.
} FOLDER_ENUM_MODE;

[
    uuid(6a9d9026-0e6e-464c-b000-42ecc07de673),
    object,
    pointer_default(unique)
]
interface IObjectWithFolderEnumMode : IUnknown
{
    HRESULT SetMode([in] FOLDER_ENUM_MODE feMode);
    HRESULT GetMode([out] FOLDER_ENUM_MODE *pfeMode);
}

// Passed to IShellFolder::ParseDisplayName
// The IDList returned should be bound to the provided Progid's association handler.
cpp_quote("#define STR_PARSE_WITH_EXPLICIT_PROGID L\"ExplicitProgid\"")

// pass to IShellFolder::ParseDisplayName
// The IDList returned should be bound to the provided Application's association handler.
cpp_quote("#define STR_PARSE_WITH_EXPLICIT_ASSOCAPP L\"ExplicitAssociationApp\"")

// returned from IShellFolder::ParseDisplayName
// The returned IDList was bound to the Progid specified with STR_PARSE_WITH_EXPLICIT_PROGID or the application specified
// with STR_PARSE_WITH_EXPLICIT_ASSOCAPP.  When absent, the Progid or Application was not bound into the IDList.
cpp_quote("#define STR_PARSE_EXPLICIT_ASSOCIATION_SUCCESSFUL L\"ExplicitAssociationSuccessful\"")

// IShellFolder IBindCtx parameter: "ParseAndCreateItem"
//
// The IUnknown for this is accessed through IBindCtx::RegisterObjectParam/GetObjectParam.
//
// Data sources should support this bind context parameter in their IShellFolder::ParseDisplayName
// implementations, in order to optimize the behavior of SHCreateItemFromParsingName().  Normally, 
// SHCreateItemFromParsingName must perform two binds to the name that is parsed: one to parse via 
// IShellFolder::ParseDisplayName(), and a subsequent bind to create the ShellItem.
// Supporting this bind context parameter in the data source avoids the second bind.  It does so 
// because the first bind (during ParseDisplayName) will create the ShellItem at the same time and 
// stash it away via IParseAndCreateItem::SetItem.  SHCreateItemFromParsingName() then uses that ShellItem
// instead of creating one via SHCreateItemFromIDList().
// 
// This parameter applies to the last element of the name that is parsed (c:\foo\bar.txt, 
// data applies to bar.txt).

cpp_quote("#define STR_PARSE_AND_CREATE_ITEM    L\"ParseAndCreateItem\"")

interface IShellItem;

[
    object,
    uuid(67efed0e-e827-4408-b493-78f3982b685c),
    pointer_default(unique),
    local
]
interface IParseAndCreateItem : IUnknown
{
    HRESULT SetItem([in] IShellItem *psi);
    HRESULT GetItem([in] REFIID riid, [out, iid_is(riid)] void **ppv);      // Returns IShellItem
};

// IShellFolder IBindCtx parameter: "ItemCacheContext"
//
// The IUnknown for this is accessed through IBindCtx::RegisterObjectParam/GetObjectParam.
// The implementation should be a separate BindContext object.  
//
// Data sources should support this bind context parameter in their IShellFolder::ParseDisplayName
// and IPersistFolder3::InitializeEx implementations, in order to cache expensive
// helper objects that can live across instantiations of shell items (instead of re-creating these
// internal objects each time a shell item is created).  
//
// A caller must opt-in to this behavior by providing this bind context parameter when calling
// SHCreateItemFromParsingName(), to optimize the behavior of binding to multiple parsing
// names in succession.  The lifetime of this object should span across multiple instances 
// of shell items and their individual bind contexts.

cpp_quote("#define STR_ITEM_CACHE_CONTEXT       L\"ItemCacheContext\"")

cpp_quote("#endif // NTDDI_VERSION >= NTDDI_WIN7")

interface IShellFolder;
[
    uuid(000214E6-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]

interface IShellFolder : IUnknown
{
midl_pragma warning (disable: 2495) // annotation is allowed on local interface and local methods only

    HRESULT ParseDisplayName(
        [in, unique] HWND hwnd,
        [in, unique] IBindCtx *pbc,
        [in, string] LPWSTR pszDisplayName,
        [in, out, unique, annotation("__reserved")] ULONG *pchEaten,
        [out] PIDLIST_RELATIVE *ppidl,
        [in, out, unique] ULONG *pdwAttributes);

midl_pragma warning (default: 2495)

    HRESULT EnumObjects(
        [in, unique] HWND hwnd,
        [in] SHCONTF grfFlags,
        [out] IEnumIDList **ppenumIDList);

    // returns an instance of a sub-folder which is specified by the IDList (pidl).
    // IShellFolder or derived interfaces
    HRESULT BindToObject(
        [in] PCUIDLIST_RELATIVE pidl,
        [in, unique] IBindCtx *pbc,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    // produces the same result as BindToObject()
    HRESULT BindToStorage(
        [in] PCUIDLIST_RELATIVE pidl,
        [in, unique] IBindCtx *pbc,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    // compares two IDLists and returns the result. The shell
    // explorer always passes 0 as lParam, which indicates 'sort by name'.
    // It should return 0 (as CODE of the scode), if two id indicates the
    // same object; negative value if pidl1 should be placed before pidl2;
    // positive value if pidl2 should be placed before pidl1.
    // use the macro ResultFromShort() to extract the result comparison
    // it deals with the casting and type conversion issues for you
    HRESULT CompareIDs(
        [in] LPARAM lParam,
        [in] PCUIDLIST_RELATIVE pidl1,
        [in] PCUIDLIST_RELATIVE pidl2);

    // creates a view object of the folder itself. The view
    // object is a difference instance from the shell folder object.
    // 'hwndOwner' can be used  as the owner window of its dialog box or
    // menu during the lifetime of the view object.
    // This member function should always create a new
    // instance which has only one reference count. The explorer may create
    // more than one instances of view object from one shell folder object
    // and treat them as separate instances.
    // returns IShellView derived interface
    HRESULT CreateViewObject(
        [in, unique] HWND hwndOwner,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    // returns the attributes of specified objects in that
    // folder. 'cidl' and 'apidl' specifies objects. 'apidl' contains only
    // simple IDLists. The explorer initializes *prgfInOut with a set of
    // flags to be evaluated. The shell folder may optimize the operation
    // by not returning unspecified flags.
    HRESULT GetAttributesOf(
        [in] UINT cidl,
        [in, size_is(cidl), unique] PCUITEMID_CHILD_ARRAY apidl,
        [in, out] SFGAOF * rgfInOut);

midl_pragma warning (disable: 2495) // annotation is allowed on local interface and local methods only

    // creates a UI object to be used for specified objects.
    // The shell explorer passes either IID_IDataObject (for transfer operation)
    // or IID_IContextMenu (for context menu operation) as riid
    // and many other interfaces
    HRESULT GetUIObjectOf(
        [in, unique] HWND hwndOwner,
        [in] UINT cidl,
        [in, size_is(cidl), unique] PCUITEMID_CHILD_ARRAY apidl,
        [in] REFIID riid,
        [in, out, unique, annotation("__reserved")] UINT * rgfReserved,
        [out, iid_is(riid)] void **ppv);

midl_pragma warning (default: 2495)

    // returns the display name of the specified object.
    // If the ID contains the display name (in the locale character set),
    // it returns the offset to the name. Otherwise, it returns a pointer
    // to the display name string (UNICODE), which is allocated by the
    // task allocator, or fills in a buffer.
    // use the helper APIS StrRetToStr() or StrRetToBuf() to deal with the different
    // forms of the STRRET structure
    HRESULT GetDisplayNameOf(
        [in, unique] PCUITEMID_CHILD pidl,
        [in] SHGDNF uFlags,
        [out] STRRET *pName);

    // sets the display name of the specified object.
    // If it changes the ID as well, it returns the new ID which is
    // alocated by the task allocator.
    [local]
    HRESULT SetNameOf(
        [in, unique, annotation("__in_opt")] HWND hwnd,
        [in, annotation("__in")] PCUITEMID_CHILD pidl,
        [in, string, annotation("__in")] LPCWSTR pszName,
        [in, annotation("__in")] SHGDNF uFlags,
        [out, annotation("__deref_opt_out")] PITEMID_CHILD *ppidlOut);

    [call_as(SetNameOf)]
    HRESULT RemoteSetNameOf(
        [in, unique] HWND hwnd,
        [in] PCUITEMID_CHILD pidl,
        [in, string] LPCWSTR pszName,
        [in] SHGDNF uFlags,
        [out] PITEMID_CHILD *ppidlOut);
}
typedef IShellFolder * LPSHELLFOLDER;


typedef struct EXTRASEARCH
{
    GUID    guidSearch;
    WCHAR   wszFriendlyName[80];
    WCHAR   wszUrl[2084];
} EXTRASEARCH, *LPEXTRASEARCH;

[
    uuid(0E700BE1-9DB6-11d1-A1CE-00C04FD75D13),
    object,
    pointer_default(unique)
]
interface IEnumExtraSearch : IUnknown
{
    HRESULT Next(
        [in] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched)] EXTRASEARCH *rgelt,
        [out] ULONG *pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumExtraSearch **ppenum);
}
typedef IEnumExtraSearch *LPENUMEXTRASEARCH;

// IShellFolder2::GetDefaultColumnState values

[
    uuid(93F2F68C-1D1B-11d3-A30E-00C04F79ABD1),
    object,
    pointer_default(unique)
]
interface IShellFolder2 : IShellFolder
{
    // Returns the guid of the search that is to be invoked when user clicks on the search toolbar button
    HRESULT GetDefaultSearchGUID([out] GUID *pguid);

    // gives an enumerator of the searches to be added to the search menu
    HRESULT EnumSearches([out] IEnumExtraSearch **ppenum);

    HRESULT GetDefaultColumn(
        [in] DWORD dwRes,
        [out] ULONG *pSort,
        [out] ULONG *pDisplay);

    // return SHCOLSTATE_ values
    HRESULT GetDefaultColumnState(
        [in] UINT iColumn,
        [out] SHCOLSTATEF *pcsFlags);

    // PCUITEMID_CHILD should have been annotated as [in].
    // Changing the annotation will break compatibility, but GetDetailsEx should never be called with a null pidl.
    HRESULT GetDetailsEx(
        [in, unique] PCUITEMID_CHILD pidl,
        [in] const SHCOLUMNID *pscid,
        [out] VARIANT *pv);

    HRESULT GetDetailsOf(
        [in, unique] PCUITEMID_CHILD pidl,
        [in] UINT iColumn,
        [out] SHELLDETAILS *psd);

    HRESULT MapColumnToSCID(
        [in] UINT iColumn,
        [out] SHCOLUMNID *pscid);
}

// FOLDERSETTINGS is a data structure that explorer passes from one folder
// view to another, when the user is browsing. It calls ISV::GetCurrentInfo
// member to get the current settings and pass it to ISV::CreateViewWindow
// to allow the next folder view 'inherit' it. These settings assumes a
// particular UI (which the shell's folder view has), and shell extensions
// may or may not use those settings.

typedef char * LPVIEWSETTINGS;

typedef [v1_enum] enum FOLDERFLAGS
{
    // XP flags
    FWF_NONE =                  0x00000000,
    FWF_AUTOARRANGE =           0x00000001,
    FWF_ABBREVIATEDNAMES =      0x00000002,     // not supported
    FWF_SNAPTOGRID =            0x00000004,
    FWF_OWNERDATA =             0x00000008,     // not supported
    FWF_BESTFITWINDOW =         0x00000010,
    FWF_DESKTOP =               0x00000020,     // implies NOCLIENTEDGE/NOSCROLL
    FWF_SINGLESEL =             0x00000040,
    FWF_NOSUBFOLDERS =          0x00000080,
    FWF_TRANSPARENT =           0x00000100,
    FWF_NOCLIENTEDGE =          0x00000200,     // not supported, this is always assumed to be true
    FWF_NOSCROLL =              0x00000400,
    FWF_ALIGNLEFT =             0x00000800,
    FWF_NOICONS =               0x00001000,
    FWF_SHOWSELALWAYS =         0x00002000,
    FWF_NOVISIBLE =             0x00004000,
    FWF_SINGLECLICKACTIVATE =   0x00008000,     // not supported
    FWF_NOWEBVIEW =             0x00010000,     // not supported
    FWF_HIDEFILENAMES =         0x00020000,
    FWF_CHECKSELECT =           0x00040000,     // check boxes with 2 modes { unchecked, SVSI_CHECK }

    // Vista Flags
    FWF_NOENUMREFRESH =         0x00080000,
    FWF_NOGROUPING =            0x00100000,
    FWF_FULLROWSELECT =         0x00200000,
    FWF_NOFILTERS =             0x00400000,
    FWF_NOCOLUMNHEADER =        0x00800000,     // don't show column header
    FWF_NOHEADERINALLVIEWS =    0x01000000,     // don't show column header if not in details mode
    FWF_EXTENDEDTILES =         0x02000000,
    FWF_TRICHECKSELECT =        0x04000000,     // checks boxes have 3 modes { unchecked, SVSI_CHECK, SVSI_CHECK2 }
    FWF_AUTOCHECKSELECT =       0x08000000,     // check boxes to change item selection state
    FWF_NOBROWSERVIEWSTATE =    0x10000000,
    FWF_SUBSETGROUPS =          0x20000000,
    FWF_USESEARCHFOLDER =       0x40000000,     // Use the search folder for stacking and searching
    FWF_ALLOWRTLREADING =       0x80000000,     // Do not use WS_EX_RTLREADING when WS_EX_LAYOUTRTL is set (thereby keeping RTL reading)
} FOLDERFLAGS;

cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(FOLDERFLAGS)")  // some bits are flags, others are not

typedef [v1_enum] enum FOLDERVIEWMODE
{
    FVM_AUTO =             -1,
    FVM_FIRST =             1,
    FVM_ICON =              1,
    FVM_SMALLICON =         2,
    FVM_LIST =              3,
    FVM_DETAILS =           4,
    FVM_THUMBNAIL =         5,
    FVM_TILE =              6,
    FVM_THUMBSTRIP =        7,
    FVM_CONTENT =           8,
    FVM_LAST =              8,
} FOLDERVIEWMODE;

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

typedef [v1_enum] enum FOLDERLOGICALVIEWMODE
{
    FLVM_UNSPECIFIED =     -1,
    FLVM_FIRST =            1,
    FLVM_DETAILS =          1,
    FLVM_TILES =            2,
    FLVM_ICONS =            3,
    FLVM_LIST =             4,
    FLVM_CONTENT =          5,
    FLVM_LAST =             5,
} FOLDERLOGICALVIEWMODE;

cpp_quote("#endif  // NTDDI_VISTA")

typedef struct FOLDERSETTINGS
{
    UINT /* FOLDERVIEWMODE */ ViewMode;     // View mode
    UINT /* FOLDERFLAGS */ fFlags;          // View options
} FOLDERSETTINGS;

typedef FOLDERSETTINGS *LPFOLDERSETTINGS;
typedef const FOLDERSETTINGS * LPCFOLDERSETTINGS;
typedef FOLDERSETTINGS *PFOLDERSETTINGS;

[
    uuid(3cc974d2-b302-4d36-ad3e-06d93f695d3f),
    object,
    pointer_default(unique)
]
interface IFolderViewOptions : IUnknown
{
    typedef [v1_enum] enum FOLDERVIEWOPTIONS
    {
        FVO_DEFAULT               = 0x00000000, // default needs none of these options and will use Itemsview
        FVO_VISTALAYOUT           = 0x00000001, // always use listview to maintain vista parity
        FVO_CUSTOMPOSITION        = 0x00000002, // requires the custom positioning of items within the X,Y space of the view
        FVO_CUSTOMORDERING        = 0x00000004, // requires the custom reordering feature of the view
        FVO_SUPPORTHYPERLINKS     = 0x00000008, // requires the use of hyperlinks in tiles and details modes
        FVO_NOANIMATIONS          = 0x00000010, // turn off animations within the view
        FVO_NOSCROLLTIPS          = 0x00000020, // turn off scroll tips 
    } FOLDERVIEWOPTIONS;

    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(FOLDERVIEWOPTIONS)")

    HRESULT SetFolderViewOptions(
               [in] FOLDERVIEWOPTIONS fvoMask,
               [in] FOLDERVIEWOPTIONS fvoFlags);

    HRESULT GetFolderViewOptions(
               [out] FOLDERVIEWOPTIONS *pfvoFlags);
}


//
// IShellView::GetWindow(phwnd)
//
//   Inherited from IOleWindow::GetWindow.
//
//
// IShellView::ContextSensitiveHelp(fEnterMode)
//
//   Inherited from IOleWindow::ContextSensitiveHelp.
//
//
// IShellView::TranslateAccelerator(lpmsg)
//
//   Similar to IOleInPlaceActiveObject::TranlateAccelerator. The explorer
//  calls this function BEFORE any other translation. Returning S_OK
//  indicates that the message was translated (eaten) and should not be
//  translated or dispatched by the explorer.
//
//
// IShellView::EnableModeless(fEnable)
//   Similar to IOleInPlaceActiveObject::EnableModeless.
//
//
// IShellView::UIActivate(uState)
//
//   The explorer calls this member function whenever the activation
//  state of the view window is changed by a certain event that is
//  NOT caused by the shell view itself.
//
//   SVUIA_DEACTIVATE will be passed when the explorer is about to
//  destroy the shell view window; the shell view is supposed to remove
//  all the extended UIs (typically merged menu and modeless popup windows).
//
//   SVUIA_ACTIVATE_NOFOCUS will be passsed when the shell view is losing
//  the input focus or the shell view has been just created without the
//  input focus; the shell view is supposed to set menuitems appropriate
//  for non-focused state (no selection specific items should be added).
//
//   SVUIA_ACTIVATE_FOCUS will be passed when the explorer has just
//  created the view window with the input focus; the shell view is
//  supposed to set menuitems appropriate for focused state.
//
//   SVUIA_INPLACEACTIVATE(new) will be passed when the shell view is opened
//  within an ActiveX control, which is not a UI active. In this case,
//  the shell view should not merge menus or put toolbas. To be compatible
//  with Win95 client, we don't pass this value unless the view supports
//  IShellView2.
//
//   The shell view should not change focus within this member function.
//  The shell view should not hook the WM_KILLFOCUS message to remerge
//  menuitems. However, the shell view typically hook the WM_SETFOCUS
//  message, and re-merge the menu after calling IShellBrowser::
//  OnViewWindowActivated.
//
//   One of the ACTIVATE / INPLACEACTIVATE messages will be sent when
//  the view window becomes the currently displayed view.  On Win95 systems,
//  this will happen immediately after the CreateViewWindow call.  On IE4, Win98,
//  and NT5 systems this may happen when the view reports it is ready (if the
//  IShellView supports async creation).  This can be used as a hint as to when
//  to make your view window visible.  Note: the Win95/Win98/NT4 common dialogs
//  do not send either of these on creation.
//
//
// IShellView::Refresh()
//
//   The explorer calls this member when the view needs to refresh its
//  contents (such as when the user hits F5 key).
//
//
// IShellView::CreateViewWindow
//
//   This member creates the view window (right-pane of the explorer or the
//  client window of the folder window).
//
//
// IShellView::DestroyViewWindow
//
//   This member destroys the view window.
//
//
// IShellView::GetCurrentInfo
//
//   This member returns the folder settings.
//
//
// IShellView::AddPropertySHeetPages
//
//   The explorer calls this member when it is opening the option property
//  sheet. This allows the view to add additional pages to it.
//
//
// IShellView::SaveViewState()
//
//   The explorer calls this member when the shell view is supposed to
//  store its view settings. The shell view is supposed to get a view
//  stream by calling IShellBrowser::GetViewStateStream and store the
//  current view state into that stream.
//
//
// IShellView::SelectItem(pidlItem, uFlags)
//
//   The explorer calls this member to change the selection state of
//  item(s) within the shell view window.  If pidlItem is NULL and uFlags
//  is SVSI_DESELECTOTHERS, all items should be deselected.

typedef [v1_enum] enum _SVSIF // Shell View Select Item Flags (SVSIF)
{
    SVSI_DESELECT        = 0x00000000,
    SVSI_SELECT          = 0x00000001,
    SVSI_EDIT            = 0x00000003,  // includes SVSI_SELECT
    SVSI_DESELECTOTHERS  = 0x00000004,
    SVSI_ENSUREVISIBLE   = 0x00000008,
    SVSI_FOCUSED         = 0x00000010,
    SVSI_TRANSLATEPT     = 0x00000020,
    SVSI_SELECTIONMARK   = 0x00000040,
    SVSI_POSITIONITEM    = 0x00000080,
    SVSI_CHECK           = 0x00000100,
    SVSI_CHECK2          = 0x00000200,
    SVSI_KEYBOARDSELECT  = 0x00000401,  // includes SVSI_SELECT
    SVSI_NOTAKEFOCUS     = 0x40000000,
} _SVSIF;

cpp_quote("#define SVSI_NOSTATECHANGE   ((UINT)0x80000000) // work around the use of the high bit that results in 4245: signed/unsigned mismatch")

typedef UINT SVSIF; // Shell View Select Item Flags (SVSIF), values from _SVSIF

typedef [v1_enum] enum _SVGIO // Shell View Get Item Object flags (SVGIO), used with IShellView::GetItemObject() and other methods
{
    SVGIO_BACKGROUND        = 0x00000000,   // riid == IID_IDispatch -> view automation object, implements supports connection point container for DIID_DShellFolderViewEvents
                                            // riid == IID_IContextMenu -> backgroud context menu object
                                            // riid == IID_IPersistHistory -> persist history object for the view
    SVGIO_SELECTION         = 0x00000001,   // the selected items in the view
    SVGIO_ALLVIEW           = 0x00000002,   // all of the items in the view
    SVGIO_CHECKED           = 0x00000003,   // if the view is in check select mode the checked items
    SVGIO_TYPE_MASK         = 0x0000000F,   // mask for above values
    SVGIO_FLAG_VIEWORDER    = 0x80000000,   // request items in view order
} _SVGIO;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(_SVGIO)")

typedef int SVGIO; // Shell View Get Item Object flags (SVGIO), values from _SVGIO

// uState values for IShellView::UIActivate
typedef [v1_enum] enum SVUIA_STATUS
{
    SVUIA_DEACTIVATE       = 0,
    SVUIA_ACTIVATE_NOFOCUS = 1,
    SVUIA_ACTIVATE_FOCUS   = 2,
    SVUIA_INPLACEACTIVATE  = 3          // new flag for IShellView2
} SVUIA_STATUS;

//  this is to handle name collisions
cpp_quote("#ifdef _FIX_ENABLEMODELESS_CONFLICT")
cpp_quote("#define    EnableModeless EnableModelessSV")
cpp_quote("#endif")

//
//  this is so that all the implementations still get the function pointer.
//  and midl wont complain about the data type
//
cpp_quote("#ifdef _NEVER_")
typedef LPARAM LPFNSVADDPROPSHEETPAGE;
cpp_quote("#else //!_NEVER_")
cpp_quote("#include <prsht.h>")
cpp_quote("typedef LPFNADDPROPSHEETPAGE LPFNSVADDPROPSHEETPAGE;")
cpp_quote("#endif //_NEVER_")

interface IShellBrowser;

[
    uuid(000214E3-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface IShellView : IOleWindow
{
    HRESULT TranslateAccelerator([in] MSG *pmsg);

    HRESULT EnableModeless([in] BOOL fEnable);

    HRESULT UIActivate([in] UINT /* SVUIA_STATUS */ uState);

    HRESULT Refresh();

    HRESULT CreateViewWindow(
        [in, unique] IShellView *psvPrevious,
        [in] LPCFOLDERSETTINGS pfs,
        [in] IShellBrowser *psb,
        [in] RECT *prcView,
        [out] HWND *phWnd);

    HRESULT DestroyViewWindow();

    HRESULT GetCurrentInfo([out] LPFOLDERSETTINGS pfs);

    [local] HRESULT AddPropertySheetPages(
        [in, annotation("__in")] DWORD dwReserved,
        [in, annotation("__in")] LPFNSVADDPROPSHEETPAGE pfn,
        [in, annotation("__in")] LPARAM lparam);

    HRESULT SaveViewState();

    HRESULT SelectItem(
        [in, unique] PCUITEMID_CHILD pidlItem,
        [in] SVSIF uFlags);

    HRESULT GetItemObject(
        [in] UINT /* SVGIO */ uItem,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

typedef IShellView *LPSHELLVIEW;
}

[
    uuid(88E39E80-3578-11CF-AE69-08002B2E1262),
    object,
    pointer_default(unique)
]
interface IShellView2 :  IShellView
{
typedef GUID SHELLVIEWID;

cpp_quote("#define SV2GV_CURRENTVIEW ((UINT)-1)")
cpp_quote("#define SV2GV_DEFAULTVIEW ((UINT)-2)")
//
//  NOTE if the cbSize param is ever updated,")
//  then there will have to be custom [wire_marshal]")
//  implementation to support it")
//
cpp_quote("#include <pshpack8.h>")
typedef struct _SV2CVW2_PARAMS
{
    DWORD cbSize;

    IShellView *psvPrev;
    LPCFOLDERSETTINGS pfs;
    IShellBrowser *psbOwner;
    RECT *prcView;
    SHELLVIEWID const *pvid;
    HWND hwndView;

} SV2CVW2_PARAMS, *LPSV2CVW2_PARAMS;

cpp_quote("#include <poppack.h>")   // Return to byte packing

    HRESULT GetView(
        [in, out] SHELLVIEWID* pvid,
        [in] ULONG uView);

    HRESULT CreateViewWindow2(
        [in] LPSV2CVW2_PARAMS lpParams);

    HRESULT HandleRename(
        [in, unique] PCUITEMID_CHILD pidlNew);

    HRESULT SelectAndPositionItem(
        [in, unique] PCUITEMID_CHILD pidlItem,
        [in] UINT /* SVSIF */ uFlags,
        [in, unique] POINT *ppt);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

[
    uuid(ec39fa88-f8af-41c5-8421-38bed28f4673),
    object,
    pointer_default(unique)
]
interface IShellView3 :  IShellView2
{
    [v1_enum] enum _SV3CVW3_FLAGS
    {
        SV3CVW3_DEFAULT             = 0x00000000,
        SV3CVW3_NONINTERACTIVE      = 0x00000001,    // Instead of bringing up UI, fail silently.
        SV3CVW3_FORCEVIEWMODE       = 0x00000002,    // Prefer view mode set by CreateViewWindow3 over saved view state
        SV3CVW3_FORCEFOLDERFLAGS    = 0x00000004,    // Prefer folder flags set by CreateViewWindow3 over saved view state
    };
    typedef DWORD SV3CVW3_FLAGS;

    HRESULT CreateViewWindow3(
        [in] IShellBrowser *psbOwner,
        [in, unique] IShellView *psvPrev,
        [in] SV3CVW3_FLAGS dwViewFlags,
        [in] FOLDERFLAGS dwMask,
        [in] FOLDERFLAGS dwFlags,
        [in] FOLDERVIEWMODE fvMode,
        [in, unique] const SHELLVIEWID *pvid,
        [in] const RECT *prcView,
        [out] HWND *phwndView);
}

cpp_quote("#endif  // NTDDI_VISTA")

//  this is to handle name collisions
cpp_quote("#ifdef _FIX_ENABLEMODELESS_CONFLICT")
cpp_quote("#undef    EnableModeless ")
cpp_quote("#endif")

[
    uuid(cde725b0-ccc9-4519-917e-325d72fab4ce),
    object,
    pointer_default(unique)
]
interface IFolderView : IUnknown
{
    HRESULT GetCurrentViewMode([out] UINT /* FOLDERVIEWMODE */ *pViewMode);

    HRESULT SetCurrentViewMode([in] UINT /* FOLDERVIEWMODE */ ViewMode);

    // the folder for the view, returns IShellFolder and related interfaces
    // also supports IShellItemArray that returns an array with a single item for the folder
    HRESULT GetFolder(
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT Item(
        [in] int iItemIndex,
        [out] PITEMID_CHILD *ppidl);

    // get the count of items for selection, total, etc
    HRESULT ItemCount(
        [in] UINT /* SVGIO */ uFlags,
        [out] int *pcItems);

    // get the items in the view in the form of IShellItemArray, IDataObject, etc
    HRESULT Items(
        [in] UINT /* SVGIO */ uFlags,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetSelectionMarkedItem([out] int *piItem);

    HRESULT GetFocusedItem([out] int *piItem);

    HRESULT GetItemPosition(
        [in] PCUITEMID_CHILD pidl,
        [out] POINT* ppt);

    HRESULT GetSpacing([in, out, unique] POINT* ppt);

    HRESULT GetDefaultSpacing([out] POINT* ppt);

    // returns S_OK if AutoArrange is on, S_FALSE if off
    HRESULT GetAutoArrange();

    // like IShellView::SelectItem() by index, SVSI_ flags
    HRESULT SelectItem(
        [in] int iItem,
        [in] DWORD /* SVSIF */ dwFlags);

#ifdef ALLOW_DISABLE_CONSISTENCY_CHECK
    HRESULT SelectAndPositionItems(
        [in] UINT cidl,
        [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl,
        [disable_consistency_check, in, unique, size_is(cidl)] POINT* apt,
        [in] DWORD /* SVSIF */ dwFlags);
#else
    HRESULT SelectAndPositionItems(
        [in] UINT cidl,
        [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl,
        [in, unique, size_is(cidl)] POINT* apt,
        [in] DWORD /* SVSIF */ dwFlags);
#endif
}
cpp_quote("#define SID_SFolderView IID_IFolderView    // folder view, usually IFolderView")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN7)")
// to discover the search box, use IServiceProvider::QueryService() using SID_SSearchBoxInfo on a site pointer within the explorer window
[
    uuid(6af6e03f-d664-4ef4-9626-f7e0ed36755e),
    object
]
interface ISearchBoxInfo : IUnknown
{
    HRESULT GetCondition(
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);    
        
    HRESULT GetText([out, string] LPWSTR *ppsz);
}        
cpp_quote("#endif // (NTDDI_VERSION >= NTDDI_WIN7)")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA) || (_WIN32_IE >= _WIN32_IE_IE70)")

cpp_quote("#ifndef NO_SHOBJIDL_SORTDIRECTION")
[v1_enum] enum tagSORTDIRECTION
{
    SORT_DESCENDING = -1,
    SORT_ASCENDING = 1
};
cpp_quote("#endif  // NO_SHOBJIDL_SORTDIRECTION")
typedef int SORTDIRECTION;

typedef struct SORTCOLUMN
{
    PROPERTYKEY   propkey;
    SORTDIRECTION direction;
} SORTCOLUMN;

typedef [v1_enum] enum FVTEXTTYPE
{
    FVST_EMPTYTEXT  = 0,
} FVTEXTTYPE;

interface IShellItemArray;

typedef HRESULT DEPRECATED_HRESULT;
cpp_quote("#if defined(__cplusplus)")
cpp_quote("#define DEPRECATED_HRESULT HRESULT DECLSPEC_DEPRECATED")
cpp_quote("#endif")

[
    uuid(1af3a467-214f-4298-908e-06b03e0b39f9),
    object,
    pointer_default(unique)
]
interface IFolderView2 : IFolderView
{
    // Sets the group by property and starts a grouping operation
    HRESULT SetGroupBy(
        [in] REFPROPERTYKEY key,
        [in] BOOL fAscending);

    [local]
    HRESULT GetGroupBy(
        [out, annotation("__out")] PROPERTYKEY* pkey,
        [out, annotation("__out_opt")] BOOL *pfAscending);

    [call_as(GetGroupBy)]
    HRESULT RemoteGetGroupBy(
        [out] PROPERTYKEY* pkey,
        [out] BOOL *pfAscending);

    // Setting and Getting per item view properties is not possible for Libraries or Search results views.
    // Consider using existing item properties instead.
    DEPRECATED_HRESULT SetViewProperty(
        [in] PCUITEMID_CHILD pidl,
        [in] REFPROPERTYKEY propkey,
        [in] REFPROPVARIANT propvar);

    // Setting and Getting per item view properties is not possible for Libraries or Search results views.
    // Consider using existing item properties instead.
    DEPRECATED_HRESULT GetViewProperty(
        [in] PCUITEMID_CHILD pidl,
        [in] REFPROPERTYKEY propkey,
        [out] PROPVARIANT *ppropvar);

    // Setting per item Tile view properties is not possible for Libraries or Search results views.
    // Consider setting property lists for your item types instead (see PKEY_PropList_TileInfo)
    DEPRECATED_HRESULT SetTileViewProperties(
        [in] PCUITEMID_CHILD pidl,
        [in, string] LPCWSTR pszPropList);

    // Setting per item Extended Tile view properties is not possible for Libraries or Search results views.
    // Consider setting property lists for your item types instead (see PKEY_PropList_ExtendedTileInfo)
    DEPRECATED_HRESULT SetExtendedTileViewProperties(
        [in] PCUITEMID_CHILD pidl,
        [in, string] LPCWSTR pszPropList);

    HRESULT SetText(
        [in] FVTEXTTYPE iType,
        [in] LPCWSTR pwszText);

    HRESULT SetCurrentFolderFlags(
        [in] DWORD /* FOLDERFLAGS */ dwMask,
        [in] DWORD /* FOLDERFLAGS */ dwFlags);

    HRESULT GetCurrentFolderFlags([out] DWORD /* FOLDERFLAGS */ *pdwFlags);

    HRESULT GetSortColumnCount([out] int *pcColumns);

    // Sets the sort by property and starts a sort operation
    HRESULT SetSortColumns(
        [in, size_is(cColumns)] const SORTCOLUMN *rgSortColumns,
        [in] int cColumns);

    HRESULT GetSortColumns(
        [out, size_is(cColumns)] SORTCOLUMN *rgSortColumns,
        [in] int cColumns);

    // return IShellItem for an item based on its index
    HRESULT GetItem(
        [in] int iItem,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetVisibleItem(
        [in] int iStart,
        [in] BOOL fPrevious,
        [out] int *piItem);

    HRESULT GetSelectedItem(
        [in] int iStart,
        [out] int *piItem);

    HRESULT GetSelection(
        [in] BOOL fNoneImpliesFolder,
        [out] IShellItemArray **ppsia);

    // Gets the selection state including check state.  Same as the flags for IFolderView::SelectAndPositionItems
    HRESULT GetSelectionState(
        [in] PCUITEMID_CHILD pidl,
        [out] DWORD /* SVSIF */ *pdwFlags);

    // If pszVerb is NULL, then the default verb is invoked.
    HRESULT InvokeVerbOnSelection([in, unique, string] LPCSTR pszVerb);

    // Sets default icon size if iImageSize == -1
    HRESULT SetViewModeAndIconSize(
        [in] FOLDERVIEWMODE uViewMode,
        [in] int iImageSize);

    HRESULT GetViewModeAndIconSize(
        [out] FOLDERVIEWMODE *puViewMode,
        [out] int *piImageSize);

    HRESULT SetGroupSubsetCount([in] UINT cVisibleRows);

    HRESULT GetGroupSubsetCount([out] UINT *pcVisibleRows);

    HRESULT SetRedraw([in] BOOL fRedrawOn);

    // S_OK means this view sourced the current drag drop or cut/paste operation (used by drop target objects)
    HRESULT IsMoveInSameFolder();

    HRESULT DoRename();
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

[
    uuid(ae8c987d-8797-4ed3-be72-2a47dd938db0),
    object
]
interface IFolderViewSettings : IUnknown
{
    // GetColumnPropertyList - returns IPropertyDescriptionList.  Ordered list of columns that must correspond to column enumerated
    // via ISF::GetDetailsOf. Any column from ISF::GetDetailsOf not included in this list will be marked SHCOLSTATE_SECONDARYUI
    // (or maintain SHCOLSTATE_HIDDEN)
    HRESULT GetColumnPropertyList(
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetGroupByProperty(
        [out] PROPERTYKEY *pkey,
        [out] BOOL *pfGroupAscending);

    HRESULT GetViewMode(
        [out] FOLDERLOGICALVIEWMODE *plvm);

    HRESULT GetIconSize(
        [out] UINT *puIconSize);

    HRESULT GetFolderFlags(
        [out] FOLDERFLAGS *pfolderMask,
        [out] FOLDERFLAGS *pfolderFlags);

    HRESULT GetSortColumns(
        [out, size_is(cColumnsIn), length_is(*pcColumnsOut)] SORTCOLUMN *rgSortColumns,
        [in] UINT cColumnsIn,
        [out] UINT *pcColumnsOut);

    HRESULT GetGroupSubsetCount([out] UINT *pcVisibleRows);
};

cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

[
    object,
    uuid(196bf9a5-b346-4ef0-aa1e-5dcdb76768b1),
    pointer_default(unique)
]
interface IPreviewHandlerVisuals : IUnknown
{
    HRESULT SetBackgroundColor([in] COLORREF color);

    HRESULT SetFont([in] const LOGFONTW *plf);

    HRESULT SetTextColor([in] COLORREF color);
};

[
    uuid(e693cf68-d967-4112-8763-99172aee5e5a),
    object,
    pointer_default(unique)
]
interface IVisualProperties : IUnknown
{
    typedef [v1_enum] enum VPWATERMARKFLAGS
    {
        VPWF_DEFAULT    = 0x00000000,     // Windows XP behavior
        VPWF_ALPHABLEND = 0x00000001,     // alpha blend the bitmap, assumed 24-bit color + 8-bit alpha
    } VPWATERMARKFLAGS;

    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(VPWATERMARKFLAGS)")

    HRESULT SetWatermark([in, unique] HBITMAP hbmp, [in] VPWATERMARKFLAGS vpwf);

    typedef [v1_enum] enum VPCOLORFLAGS
    {
        VPCF_TEXT           = 1,
        VPCF_BACKGROUND     = 2,
        VPCF_SORTCOLUMN     = 3,
        VPCF_SUBTEXT        = 4,
        VPCF_TEXTBACKGROUND = 5,
    } VPCOLORFLAGS; // misnamed, this is not a flags type

    HRESULT SetColor(
        [in] VPCOLORFLAGS vpcf,
        [in] COLORREF cr);

    HRESULT GetColor(
        [in] VPCOLORFLAGS vpcf,
        [out] COLORREF *pcr);

    HRESULT SetItemHeight([in] int cyItemInPixels);

    HRESULT GetItemHeight([out] int *cyItemInPixels);

    HRESULT SetFont(
        [in] const LOGFONTW* plf,
        [in] BOOL bRedraw);

    HRESULT GetFont([out] LOGFONTW* plf);

    HRESULT SetTheme(
        [in, unique, string] LPCWSTR pszSubAppName,
        [in, unique, string] LPCWSTR pszSubIdList);
}

cpp_quote("#endif  // _WIN32_IE_IE70")


//-------------------------------------------------------------------------
// ICommDlgBrowser interface
//
//  ICommDlgBrowser interface is the interface that is provided by the new
// common dialog window to hook and modify the behavior of IShellView.  When
// a default view is created, it queries its parent IShellBrowser for the
// ICommDlgBrowser interface.  If supported, it calls out to that interface
// in several cases that need to behave differently in a dialog.
//
// Member functions:
//
//  ICommDlgBrowser::OnDefaultCommand()
//    Called when the user double-clicks in the view or presses Enter.  The
//   browser should return S_OK if it processed the action itself, S_FALSE
//   to let the view perform the default action.
//
//  ICommDlgBrowser::OnStateChange(ULONG uChange)
//    Called when some states in the view change.  'uChange' is one of the
//   CDBOSC_* values.  This call is made after the state (selection, focus,
//   etc) has changed.  There is no return value.
//
//  ICommDlgBrowser::IncludeObject(PCUITEMID_CHILD pidl)
//    Called when the view is enumerating objects.  'pidl' is a relative
//   IDLIST.  The browser should return S_OK to include the object in the
//   view, S_FALSE to hide it
//
//-------------------------------------------------------------------------

cpp_quote("#define CDBOSC_SETFOCUS     0x00000000")
cpp_quote("#define CDBOSC_KILLFOCUS    0x00000001")
cpp_quote("#define CDBOSC_SELCHANGE    0x00000002")
cpp_quote("#define CDBOSC_RENAME       0x00000003")
cpp_quote("#define CDBOSC_STATECHANGE  0x00000004")

[
    uuid(000214F1-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface ICommDlgBrowser : IUnknown
{
    HRESULT OnDefaultCommand([in] IShellView *ppshv);

    HRESULT OnStateChange(
        [in] IShellView *ppshv,
        [in] ULONG uChange);

    HRESULT IncludeObject(
        [in, unique] IShellView *ppshv,
        [in] PCUITEMID_CHILD pidl);
}

typedef ICommDlgBrowser * LPCOMMDLGBROWSER;

// This is for frames that may host an ExplorerBrowser (which implements ICommDlgBrowser3), and yet need to implement
// some ICommDlgBrowser methods themselves.  ExplorerBrowser will do some default processing if necessary, and then
// allow responders to SID_SExplorerBrowserFrame to provide additional processing of these calls, when appropriate.
cpp_quote("#define SID_SExplorerBrowserFrame IID_ICommDlgBrowser")

//-------------------------------------------------------------------------
// ICommDlgBrowser2 interface
//
// Member functions:
//
//  ICommDlgBrowser2::Notify(IShellView *pshv, DWORD dwNotfyType)
//   Called when the view is wants to notify common dialog when an event
//  occurrs.
//
//  CDB2N_CONTEXTMENU_START indicates the context menu has started.
//  CDB2N_CONTEXTMENU_DONE  indicates the context menu has completed.
//
//  ICommDlgBrowser2::GetDefaultMenuText(IShellView *pshv,
//                                      WCHAR *pszText, INT cchMax)
//   Called when the view wants to get the default context menu text.
//  pszText points to buffer and cchMax specifies the size of the
//  buffer in characters.  The browser on return has filled the buffer
//  with the default context menu text.  The Shell will call this method
//  with at least a buffer size of MAX_PATH.  The browser should return
//  S_OK if it returned a new default menu text, S_FALSE to let the view
//  to use the normal default menu text.
//
//  ICommDlgBrowser2::GetViewFlags(DWORD *pdwFlags)
//     Called when the view wants to determine  if special customization needs to
//    be done for the common dialog browser. For example View calls this function to
//    determin if all files(hidden and system)needs to be shown. If the GetViewFlags returns a DWORD with
//    CDB2GVF_SHOWALLFILES  flag set then it will show all the files.
//-------------------------------------------------------------------------

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN2K)")

cpp_quote("#define CDB2N_CONTEXTMENU_DONE  0x00000001")
cpp_quote("#define CDB2N_CONTEXTMENU_START 0x00000002")

//GetViewFlags
cpp_quote("#define CDB2GVF_SHOWALLFILES        0x00000001")
cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define CDB2GVF_ISFILESAVE          0x00000002 // is file save, else file open")
cpp_quote("#define CDB2GVF_ALLOWPREVIEWPANE    0x00000004")
cpp_quote("#define CDB2GVF_NOSELECTVERB        0x00000008")
cpp_quote("#define CDB2GVF_NOINCLUDEITEM       0x00000010")
cpp_quote("#define CDB2GVF_ISFOLDERPICKER      0x00000020")
cpp_quote("#define CDB2GVF_ADDSHIELD           0x00000040   // when CDB2GVF_NOSELECTVERB is not specified this flag controls the display of a LUA shield on the Select menu item") 
cpp_quote("#endif  // NTDDI_VISTA")

[
    uuid(10339516-2894-11d2-9039-00C04F8EEB3E),
    object,
    pointer_default(unique)
]
interface ICommDlgBrowser2 : ICommDlgBrowser
{
    HRESULT Notify(
        [in] IShellView *ppshv,
        [in] DWORD dwNotifyType);

    HRESULT GetDefaultMenuText(
        [in] IShellView *ppshv,
        [out, string, size_is(cchMax)] LPWSTR pszText,
        [in] int cchMax);

    // returns CDB2GVF_XXX values to control the behavior of the view when in common dialog mode
    HRESULT GetViewFlags([out] DWORD *pdwFlags);
}

typedef ICommDlgBrowser2 * LPCOMMDLGBROWSER2;

cpp_quote("#endif  // NTDDI_WIN2K")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

[
    uuid(c8ad25a1-3294-41ee-8165-71174bd01c57),
    object,
    pointer_default(unique)
]
interface ICommDlgBrowser3 : ICommDlgBrowser2
{
    HRESULT OnColumnClicked(
        [in] IShellView *ppshv,
        [in] int iColumn);

    HRESULT GetCurrentFilter(
        [out, string, size_is(cchFileSpec)] LPWSTR pszFileSpec,
        [in] int cchFileSpec);

    HRESULT OnPreViewCreated([in] IShellView *ppshv);
}

//--------------------------------------------------------------------------
//
// Interface:   IColumnManager
//
// IColumnManager is an interfaced provided by defview to
// allow the manipulation of columns in details view.
//

typedef [v1_enum] enum CM_MASK
{
    CM_MASK_WIDTH           = 0x00000001,
    CM_MASK_DEFAULTWIDTH    = 0x00000002,
    CM_MASK_IDEALWIDTH      = 0x00000004,
    CM_MASK_NAME            = 0x00000008,
    CM_MASK_STATE           = 0x00000010,
} CM_MASK;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(CM_MASK)")

typedef [v1_enum] enum CM_STATE
{
    CM_STATE_NONE               = 0x00000000,
    CM_STATE_VISIBLE            = 0x00000001,  // The column is visible
    CM_STATE_FIXEDWIDTH         = 0x00000002,  // Can't resize the column
    CM_STATE_NOSORTBYFOLDERNESS = 0x00000004,  // Do not sort folders seperately
    CM_STATE_ALWAYSVISIBLE      = 0x00000008,  // readonly. column cannot be hidden
} CM_STATE;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(CM_STATE)")

typedef [v1_enum] enum CM_ENUM_FLAGS
{
    CM_ENUM_ALL          = 0x00000001,
    CM_ENUM_VISIBLE      = 0x00000002,
} CM_ENUM_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(CM_ENUM_FLAGS)")

typedef [v1_enum] enum CM_SET_WIDTH_VALUE
{
    CM_WIDTH_USEDEFAULT  = -1,
    CM_WIDTH_AUTOSIZE    = -2,
} CM_SET_WIDTH_VALUE;

#define MAX_COLUMN_NAME_LEN 80

typedef struct CM_COLUMNINFO
{
    DWORD cbSize;  // size in bytes of struct
    DWORD dwMask;  // CM_MASK
    DWORD dwState; // CM_STATE
    UINT uWidth;   // CM_MASK_WIDTH, for SetColumnInfo it can be a CM_SET_WIDTH_VALUE
    UINT uDefaultWidth; // CM_MASK_DEFAULTWIDTH
    UINT uIdealWidth; // CM_MASK_IDEALWIDTH
    WCHAR wszName[MAX_COLUMN_NAME_LEN];
} CM_COLUMNINFO;

[
    uuid(d8ec27bb-3f3b-4042-b10a-4acfd924d453),
    object,
    pointer_default(unique)
]
interface IColumnManager : IUnknown
{
    HRESULT SetColumnInfo(
        [in] REFPROPERTYKEY propkey,
        [in] const CM_COLUMNINFO *pcmci);

    HRESULT GetColumnInfo(
        [in] REFPROPERTYKEY propkey,
        [out] CM_COLUMNINFO *pcmci);

    HRESULT GetColumnCount(
        [in] CM_ENUM_FLAGS dwFlags,
        [out] UINT *puCount);

    HRESULT GetColumns(
        [in] CM_ENUM_FLAGS dwFlags,
        [out, size_is(cColumns)] PROPERTYKEY *rgkeyOrder,
        [in] UINT cColumns);

    HRESULT SetColumns(
        [in, size_is(cVisible)] const PROPERTYKEY *rgkeyOrder,
        [in] UINT cVisible);
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

// New for XP, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")
[
    uuid(C0A651F5-B48B-11d2-B5ED-006097C686F6), // IID_IFolderFilterSite
    object,
    pointer_default(unique)
]
interface IFolderFilterSite : IUnknown
{
    HRESULT SetFilter([in]IUnknown* punk);
}

[
    uuid(9CC22886-DC8E-11d2-B1D0-00C04F8EEB3E), // IID_IFolderFilter
    object,
    pointer_default(unique)
]
interface IFolderFilter : IUnknown
{
    HRESULT ShouldShow(
        [in] IShellFolder* psf,
        [in, unique] PCIDLIST_ABSOLUTE pidlFolder,
        [in] PCUITEMID_CHILD pidlItem);

    HRESULT GetEnumFlags(
        [in] IShellFolder* psf,
        [in] PCIDLIST_ABSOLUTE pidlFolder,
        [out] HWND *phwnd,
        [in, out] DWORD *pgrfFlags);
}
//cpp_quote("#endif  // NTDDI_WINXP")

//==========================================================================
// IInputObjectSite/IInputObject interfaces
//
// These interfaces allow us (or ISVs) to install/update external Internet
// Toolbar for IE and the shell. The frame will simply get the CLSID from
// registry (to be defined) and CoCreateInstance it.
//
//==========================================================================

// A site implements this interface so the object can communicate
// focus change to it.
[
    object,
    uuid(F1DB8392-7331-11D0-8C99-00A0C92DBFE8),
    pointer_default(unique),
]
interface IInputObjectSite: IUnknown
{
    // Object (punkObj) is getting or losing the focus.
    HRESULT OnFocusChangeIS([in, unique] IUnknown* punkObj, [in] BOOL fSetFocus);
}

[
    object,
    uuid(68284fAA-6A48-11D0-8c78-00C04fd918b4),
    pointer_default(unique)
]
interface IInputObject: IUnknown
{
    // Activates or deactivates the object.  lpMsg may be NULL.  Returns
    // S_OK if the activation succeeded.
    HRESULT UIActivateIO([in] BOOL fActivate, [in, unique] MSG *pMsg);

    // Returns S_OK if the object has the focus, S_FALSE if not.
    HRESULT HasFocusIO();

    // Allow the object to process the message.  Returns S_OK if the
    // message was processed (eaten).
    HRESULT TranslateAcceleratorIO([in] MSG *pMsg);
}


// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
[
    object,
    uuid(6915C085-510B-44cd-94AF-28DFA56CF92B),
    pointer_default(unique),
    local
]
interface IInputObject2 : IInputObject
{
    // Called to handle global accelerators, so that input objects can
    // respond to keyboard even when they are not UI active.
    //
    // Note that pMsg is not const, to allow implementors to forward to the
    // Win32 TranslateAccelerator without having to cast away const-ness.
    HRESULT TranslateAcceleratorGlobal([in, annotation("__in")] MSG *pMsg);
}
//cpp_quote("#endif  // NTDDI_VISTA")

//===========================================================================
//
// IShellIcon Interface
//
// used to get a icon index for a IShellFolder object.
//
// this interface can be implemented by a IShellFolder, as a quick way to
// return the icon for a object in the folder.
//
// a instance of this interface is only created once for the folder, unlike
// IExtractIcon witch is created once for each object.
//
// if a ShellFolder does not implement this interface, the standard
// GetUIObject(....IExtractIcon) method will be used to get a icon
// for all objects.
//
// the following standard imagelist indexs can be returned:
//
//      0   document (blank page) (not associated)
//      1   document (with stuff on the page)
//      2   application (exe, com, bat)
//      3   folder (plain)
//      4   folder (open)
//
// IShellIcon:GetIconOf(pidl, flags, lpIconIndex)
//
//      pidl            object to get icon for.
//      flags           GIL_* input flags (GIL_OPEN, ...)
//      lpIconIndex     place to return icon index.
//
//  returns:
//      S_OK, if lpIconIndex contains the correct system imagelist index.
//      S_FALSE, if unable to get icon for this object, go through
//               GetUIObject, IExtractIcon, methods.
//
//===========================================================================

[
    uuid(000214E5-0000-0000-C000-000000000046), // IID_IShellIcon
    object,
    pointer_default(unique)
]
interface IShellIcon : IUnknown
{
    HRESULT GetIconOf(
        [in] PCUITEMID_CHILD pidl,
        [in] UINT flags,
        [out] int *pIconIndex);
}

//--------------------------------------------------------------------------
//
// Interface:   IShellBrowser
//
//  IShellBrowser interface is the interface that is provided by the shell
// explorer/folder frame window. When it creates the 'contents pane' of
// a shell folder (which provides IShellFolder interface), it calls its
// CreateViewObject member function to create an IShellView object. Then,
// it calls its CreateViewWindow member to create the 'contents pane'
// window. The pointer to the IShellBrowser interface is passed to
// the IShellView object as a parameter to this CreateViewWindow member
// function call.
//
//    +--------------------------+  <-- Explorer window
//    | [] Explorer              |
//    |--------------------------+       IShellBrowser
//    | File Edit View ..        |
//    |--------------------------|
//    |        |                 |
//    |        |              <-------- Content pane
//    |        |                 |
//    |        |                 |       IShellView
//    |        |                 |
//    |        |                 |
//    +--------------------------+
//
//
//
// [Member functions]
//
//
// IShellBrowser::GetWindow(phwnd)
//
//   Inherited from IOleWindow::GetWindow.
//
//
// IShellBrowser::ContextSensitiveHelp(fEnterMode)
//
//   Inherited from IOleWindow::ContextSensitiveHelp.
//
//
// IShellBrowser::InsertMenusSB(hmenuShared, lpMenuWidths)
//
//   Similar to the IOleInPlaceFrame::InsertMenus. The explorer will put
//  'File' and 'Edit' pulldown in the File menu group, 'View' and 'Tools'
//  in the Container menu group and 'Help' in the Window menu group. Each
//  pulldown menu will have a uniqu ID, FCIDM_MENU_FILE/EDIT/VIEW/TOOLS/HELP
//  The view is allowed to insert menuitems into those sub-menus by those
//  IDs must be between FCIDM_SHVIEWFIRST and FCIDM_SHVIEWLAST.
//
//
// IShellBrowser::SetMenuSB(hmenuShared, holemenu, hwndActiveObject)
//
//   Similar to the IOleInPlaceFrame::SetMenu. The explorer ignores the
//  holemenu parameter (reserved for future enhancement)  and performs
//  menu-dispatch based on the menuitem IDs (see the description above).
//  It is important to note that the explorer will add different
//  set of menuitems depending on whether the view has a focus or not.
//  Therefore, it is very important to call ISB::OnViewWindowActivate
//  whenever the view window (or its children) gets the focus.
//
//
// IShellBrowser::RemoveMenusSB(hmenuShared)
//
//   Same as the IOleInPlaceFrame::RemoveMenus.
//
//
// IShellBrowser::SetStatusTextSB(pszStatusText)
//
//   Same as the IOleInPlaceFrame::SetStatusText. It is also possible to
//  send messages directly to the status window via SendControlMsg.
//
//
// IShellBrowser::EnableModelessSB(fEnable)
//
//   Same as the IOleInPlaceFrame::EnableModeless.
//
//
// IShellBrowser::TranslateAcceleratorSB(lpmsg, wID)
//
//   Same as the IOleInPlaceFrame::TranslateAccelerator, but will be
//  never called because we don't support EXEs (i.e., the explorer has
//  the message loop). This member function is defined here for possible
//  future enhancement.
//
//
// IShellBrowser::BrowseObject(pidl, wFlags)")
//
//   The view calls this member to let shell explorer browse to another")
//  folder. The pidl and wFlags specifies the folder to be browsed.")
//
//  Following three flags specifies whether it creates another window or not.
//   SBSP_SAMEBROWSER  -- Browse to another folder with the same window.
//   SBSP_NEWBROWSER   -- Creates another window for the specified folder.
//   SBSP_DEFBROWSER   -- Default behavior (respects the view option).
//
//  Following three flags specifies open, explore, or default mode. These
//  are ignored if SBSP_SAMEBROWSER or (SBSP_DEFBROWSER && (single window
//  browser || explorer)).
//   SBSP_OPENMODE     -- Use a normal folder window
//   SBSP_EXPLOREMODE  -- Use an explorer window
//   SBSP_DEFMODE      -- Use the same as the current window
//
//  Following three flags specifies the pidl.
//   SBSP_ABSOLUTE -- pidl is an absolute pidl (relative from desktop)
//   SBSP_RELATIVE -- pidl is relative from the current folder.
//   SBSP_PARENT   -- Browse the parent folder (ignores the pidl)
//   SBSP_NAVIGATEBACK    -- Navigate back (ignores the pidl)
//   SBSP_NAVIGATEFORWARD -- Navigate forward (ignores the pidl)
//
//  Following two flags control history manipulation as result of navigate
//   SBSP_WRITENOHISTORY -- write no history (shell folder) entry
//   SBSP_NOAUTOSELECT -- suppress selection in history pane
//
//
// IShellBrowser::GetViewStateStream(grfMode, ppstm)
//
//   The browser returns an IStream interface as the storage for view
//  specific state information.
//
//   grfMode -- Specifies the read/write access (STGM_READ/WRITE/READWRITE)
//   ppstm   -- Specifies the IStream *variable to be filled.
//
//
// IShellBrowser::GetControlWindow(id, phwnd)
//
//   The shell view may call this member function to get the window handle
//  of Explorer controls (toolbar or status winodw -- FCW_TOOLBAR or
//  FCW_STATUS).
//
//
// IShellBrowser::SendControlMsg(id, uMsg, wParam, lParam, pret)
//
//   The shell view calls this member function to send control messages to
//  one of Explorer controls (toolbar or status window -- FCW_TOOLBAR or
//  FCW_STATUS).
//
//
// IShellBrowser::QueryActiveShellView(IShellView * ppshv)
//
//   This member returns currently activated (displayed) shellview object.
//  A shellview never need to call this member function.
//
//
// IShellBrowser::OnViewWindowActive(pshv)
//
//   The shell view window calls this member function when the view window
//  (or one of its children) got the focus. It MUST call this member before
//  calling IShellBrowser::InsertMenus, because it will insert different
//  set of menu items depending on whether the view has the focus or not.
//
//
// IShellBrowser::SetToolbarItems(lpButtons, nButtons, uFlags)
//
//   The view calls this function to add toolbar items to the exporer's
//  toolbar. 'lpButtons' and 'nButtons' specifies the array of toolbar
//  items. 'uFlags' must be one of FCT_MERGE, FCT_CONFIGABLE, FCT_ADDTOEND.
//
//-------------------------------------------------------------------------

//
// flag values to be combined for the Flags parameter of IShellBrowser::BrowseObject() method
//
cpp_quote("#define SBSP_DEFBROWSER         0x0000")
cpp_quote("#define SBSP_SAMEBROWSER        0x0001")
cpp_quote("#define SBSP_NEWBROWSER         0x0002")

cpp_quote("#define SBSP_DEFMODE            0x0000")
cpp_quote("#define SBSP_OPENMODE           0x0010")
cpp_quote("#define SBSP_EXPLOREMODE        0x0020")
cpp_quote("#define SBSP_HELPMODE           0x0040")
cpp_quote("#define SBSP_NOTRANSFERHIST     0x0080")

cpp_quote("#define SBSP_ABSOLUTE           0x0000")
cpp_quote("#define SBSP_RELATIVE           0x1000")
cpp_quote("#define SBSP_PARENT             0x2000")
cpp_quote("#define SBSP_NAVIGATEBACK       0x4000")
cpp_quote("#define SBSP_NAVIGATEFORWARD    0x8000")

cpp_quote("#define SBSP_ALLOW_AUTONAVIGATE   0x00010000")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define SBSP_KEEPSAMETEMPLATE     0x00020000")
cpp_quote("#define SBSP_KEEPWORDWHEELTEXT    0x00040000")
cpp_quote("#define SBSP_ACTIVATE_NOFOCUS     0x00080000")
cpp_quote("#define SBSP_CREATENOHISTORY      0x00100000")
cpp_quote("#define SBSP_PLAYNOSOUND          0x00200000")
cpp_quote("#endif  // (NTDDI_VERSION >= NTDDI_VISTA)")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE60SP2)")
cpp_quote("#define SBSP_CALLERUNTRUSTED      0x00800000")
cpp_quote("#define SBSP_TRUSTFIRSTDOWNLOAD   0x01000000")
cpp_quote("#define SBSP_UNTRUSTEDFORDOWNLOAD 0x02000000")
cpp_quote("#endif  // _WIN32_IE_IE60SP2")
cpp_quote("#define SBSP_NOAUTOSELECT         0x04000000")
cpp_quote("#define SBSP_WRITENOHISTORY       0x08000000")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE60SP2)")
cpp_quote("#define SBSP_TRUSTEDFORACTIVEX    0x10000000")
cpp_quote("#endif  // _WIN32_IE_IE60SP2")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("#define SBSP_FEEDNAVIGATION       0x20000000")
cpp_quote("#endif  // _WIN32_IE_IE70")


cpp_quote("#define SBSP_REDIRECT                     0x40000000")
cpp_quote("#define SBSP_INITIATEDBYHLINKFRAME        0x80000000")
//
// Values for id parameter of ISB::GetWindow/SendControlMsg members.
//
// WARNING:
//  Any shell extensions which sends messages to those control windows
// might not work in the future version of windows. If you really need
// to send messages to them, (1) don't assume that those control window
// always exist (i.e. GetControlWindow may fail) and (2) verify the window
// class of the window before sending any messages.
//
cpp_quote("#define FCW_STATUS         0x0001")
cpp_quote("#define FCW_TOOLBAR        0x0002")
cpp_quote("#define FCW_TREE           0x0003")
cpp_quote("#define FCW_INTERNETBAR    0x0006")
cpp_quote("#define FCW_PROGRESS       0x0008")


cpp_quote("#if (_WIN32_IE >= 0x0700)")
cpp_quote("#endif")

//
// Values for uFlags paremeter of ISB::SetToolbarItems member.
//
cpp_quote("#define FCT_MERGE       0x0001")
cpp_quote("#define FCT_CONFIGABLE  0x0002")
cpp_quote("#define FCT_ADDTOEND    0x0004")

cpp_quote("#ifdef _NEVER_")
typedef LPARAM LPTBBUTTONSB;
cpp_quote("#else //!_NEVER_")
cpp_quote("#include <commctrl.h>")
cpp_quote("typedef LPTBBUTTON LPTBBUTTONSB;")
cpp_quote("#endif //_NEVER_")

[
    uuid(000214E2-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface IShellBrowser : IOleWindow
{
    // same as IOleInPlaceFrame
    HRESULT InsertMenusSB(
        [in] HMENU hmenuShared,
        [in, out] LPOLEMENUGROUPWIDTHS lpMenuWidths);

    HRESULT SetMenuSB(
        [in, unique] HMENU hmenuShared,
        [in, unique] HOLEMENU holemenuRes,
        [in, unique] HWND hwndActiveObject);

    HRESULT RemoveMenusSB([in] HMENU hmenuShared);
    HRESULT SetStatusTextSB([in, unique] LPCWSTR pszStatusText);
    HRESULT EnableModelessSB([in] BOOL fEnable);
    HRESULT TranslateAcceleratorSB([in] MSG *pmsg, [in] WORD wID);

    // IShellBrowser
    HRESULT BrowseObject(
        [in, unique] PCUIDLIST_RELATIVE pidl,
        [in] UINT wFlags);

    HRESULT GetViewStateStream(
        [in] DWORD grfMode,
        [out] IStream **ppStrm);

    HRESULT GetControlWindow(
        [in] UINT id,
        [out] HWND * phwnd);

    [local] HRESULT SendControlMsg(
        [in, annotation("__in")] UINT id,
        [in, annotation("__in")] UINT uMsg,
        [in, annotation("__in")] WPARAM wParam,
        [in, annotation("__in")] LPARAM lParam,
        [out, annotation("__out_opt")] LRESULT *pret);

    HRESULT QueryActiveShellView([out] IShellView **ppshv);

    HRESULT OnViewWindowActive([in] IShellView *pshv);

    [local] HRESULT SetToolbarItems(
        [in, annotation("__in_ecount_opt(nButtons)")] LPTBBUTTONSB lpButtons,
        [in, annotation("__in")] UINT nButtons,
        [in, annotation("__in")] UINT uFlags);
}

typedef IShellBrowser * LPSHELLBROWSER;


[
    uuid(cb728b20-f786-11ce-92ad-00aa00a74cd0), // IID_IProfferService
    object,
    pointer_default(unique)
]
interface IProfferService : IUnknown
{
    HRESULT ProfferService(
        [in] REFGUID guidService,
        [in] IServiceProvider *psp,
        [out] DWORD *pdwCookie);

    HRESULT RevokeService([in] DWORD dwCookie);
}

cpp_quote("#define SID_SProfferService IID_IProfferService    // nearest service that you can proffer to")

// Tells an IShellItem not to resolve the link target obtained
// when using the BHID_LinkTargetItem GUID in BindToHandler.
cpp_quote("#define STR_DONT_RESOLVE_LINK      L\"Don't Resolve Link\"")

// The handler is being retrieved on the UI thread.  Avoid any expensive work that touches the disk, network, etc.
cpp_quote("#define STR_GET_ASYNC_HANDLER L\"GetAsyncHandler\"")

// New for XP, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

//  BindHandler GUIDs for IShellItem::BindToHandler (defined in shlguid.h)")
//  BHID_SFObject            restricts usage to IShellFolder::BindToObject()")
//  BHID_SFUIObject          restricts usage to IShellFolder::GetUIObjectOf()")
//  BHID_SFViewObject        restricts usage to IShellFolder::CreateViewObject()")
//  BHID_LinkTargetItem      CLSID_ShellItem initialized with the target this item (SFGAO_LINK only)")
//  BHID_Storage             attempts to get the stg/stm riid from BTO, but defaults to shell implementations on failure")

//  Shell Namespace helper
[
    uuid(43826d1e-e718-42ee-bc55-a1e261c37bfe),
    object,
    pointer_default(unique)
]
interface IShellItem : IUnknown
{
    typedef [v1_enum] enum _SIGDN
    {                                                         // lower word (& with 0xFFFF)
        SIGDN_NORMALDISPLAY               = 0x00000000,       // SHGDN_NORMAL
        SIGDN_PARENTRELATIVEPARSING       = (int) 0x80018001, // SHGDN_INFOLDER | SHGDN_FORPARSING
        SIGDN_DESKTOPABSOLUTEPARSING      = (int) 0x80028000, // SHGDN_FORPARSING
        SIGDN_PARENTRELATIVEEDITING       = (int) 0x80031001, // SHGDN_INFOLDER | SHGDN_FOREDITING
        SIGDN_DESKTOPABSOLUTEEDITING      = (int) 0x8004c000, // SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
        SIGDN_FILESYSPATH                 = (int) 0x80058000, // SHGDN_FORPARSING
        SIGDN_URL                         = (int) 0x80068000, // SHGDN_FORPARSING
        SIGDN_PARENTRELATIVEFORADDRESSBAR = (int) 0x8007c001, // SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
        SIGDN_PARENTRELATIVE              = (int) 0x80080001, // SHGDN_INFOLDER
    } SIGDN;

    //  SICHINT_DISPLAY         iOrder based on display in a folder view
    //  SICHINT_ALLFIELDS       exact instance compare
    //  SICHINT_CANONICAL       iOrder based on canonical name (better performance)
    [v1_enum] enum _SICHINTF
    {
        SICHINT_DISPLAY         = 0x00000000,
        SICHINT_ALLFIELDS       = (int) 0x80000000,
        SICHINT_CANONICAL       = 0x10000000,
        SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000,
    };
    typedef DWORD SICHINTF;

    HRESULT BindToHandler(
        [in, unique] IBindCtx *pbc,
        [in] REFGUID bhid,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetParent([out] IShellItem **ppsi);

    HRESULT GetDisplayName(
        [in] SIGDN sigdnName,
        [out, string] LPWSTR *ppszName);

    HRESULT GetAttributes(
        [in] SFGAOF sfgaoMask,
        [out] SFGAOF *psfgaoAttribs);

    HRESULT Compare(
        [in] IShellItem *psi,
        [in] SICHINTF hint,
        [out] int *piOrder);
}
//cpp_quote("#endif  // NTDDI_WINXP")

cpp_quote("SHSTDAPI_(PIDLIST_ABSOLUTE) SHSimpleIDListFromPath(LPCWSTR pszPath);")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("// CLSID_ShellItem create and init helper APIs. produce IShellItem derived interfaces from these different expressions of an item")
cpp_quote("SHSTDAPI SHCreateItemFromIDList(__in PCIDLIST_ABSOLUTE pidl, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("SHSTDAPI SHCreateItemFromParsingName(__in PCWSTR pszPath, __in_opt IBindCtx *pbc, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("SHSTDAPI SHCreateItemWithParent(__in_opt PCIDLIST_ABSOLUTE pidlParent, __in_opt IShellFolder *psfParent, __in PCUITEMID_CHILD pidl, __in REFIID riid, __deref_out void **ppvItem);")
cpp_quote("SHSTDAPI SHCreateItemFromRelativeName(__in IShellItem *psiParent, __in PCWSTR pszName, __in_opt IBindCtx* pbc, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("SHSTDAPI SHCreateItemInKnownFolder(REFKNOWNFOLDERID kfid, DWORD dwKFFlags, __in_opt PCWSTR pszItem, REFIID riid, __deref_out void **ppv);")
cpp_quote("// get the IDList expression from an object, works with objects that support IPersistIDlist or IPersistIDlist like CLSID_ShellItem and most shell folders")
cpp_quote("SHSTDAPI SHGetIDListFromObject(__in IUnknown *punk, __deref_out PIDLIST_ABSOLUTE *ppidl);")
cpp_quote("// similar to SHGetIDListFromObject but returns an IShellItem-based object (preferred for performance if the IDList is already bound to a folder)")
cpp_quote("SHSTDAPI SHGetItemFromObject(__in IUnknown *punk, __in REFIID riid, __deref_out void **ppv);")

cpp_quote("// these APIs return object that support IPropertyStore or related interfaces")
cpp_quote("SHSTDAPI SHGetPropertyStoreFromIDList(__in PCIDLIST_ABSOLUTE pidl, __in GETPROPERTYSTOREFLAGS flags, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("SHSTDAPI SHGetPropertyStoreFromParsingName(__in PCWSTR pszPath, __in_opt IBindCtx *pbc, __in GETPROPERTYSTOREFLAGS flags, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("SHSTDAPI SHGetNameFromIDList(__in PCIDLIST_ABSOLUTE pidl, __in SIGDN sigdnName, __deref_out PWSTR *ppszName);")

cpp_quote("#endif // (NTDDI_VERSION >= NTDDI_VISTA)")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN7)")
typedef [v1_enum] enum DATAOBJ_GET_ITEM_FLAGS
{
    DOGIF_DEFAULT         = 0x0000,
    DOGIF_TRAVERSE_LINK   = 0x0001,    // if the item is a link get the target
    DOGIF_NO_HDROP        = 0x0002,    // don't fallback and use CF_HDROP clipboard format
    DOGIF_NO_URL          = 0x0004,    // don't fallback and use URL clipboard format
    DOGIF_ONLY_IF_ONE     = 0x0008,    // only return the item if there is one item in the array
} DATAOBJ_GET_ITEM_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(DATAOBJ_GET_ITEM_FLAGS)")
// returns IShellItem and other interfaces that CLSID_ShellItem implements
cpp_quote("STDAPI SHGetItemFromDataObject(__in IDataObject *pdtobj, __in DATAOBJ_GET_ITEM_FLAGS dwFlags, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("#endif // (NTDDI_VERSION >= NTDDI_WIN7)")

// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

//
// When requesting a property store through IShellFolder, you can specify the equivalent of
// GPS_DEFAULT by passing in a null IBindCtx parameter.
//
// You can specify the equivalent of GPS_READWRITE by passing a mode of STGM_READWRITE | STGM_EXCLUSIVE
// in the bind context
//
// Here are the string versions of GPS_ flags, passed to IShellFolder::BindToObject() via IBindCtx::RegisterObjectParam()
// These flags are valid when requesting an IPropertySetStorage or IPropertyStore handler
//
// The meaning of these flags are described above.
//
// There is no STR_ equivalent for GPS_TEMPORARY because temporary property stores
// are provided by IShellItem2 only -- not by the underlying IShellFolder.
//
cpp_quote("#define STR_GPS_HANDLERPROPERTIESONLY      L\"GPS_HANDLERPROPERTIESONLY\"")
cpp_quote("#define STR_GPS_FASTPROPERTIESONLY         L\"GPS_FASTPROPERTIESONLY\"")
cpp_quote("#define STR_GPS_OPENSLOWITEM               L\"GPS_OPENSLOWITEM\"")
cpp_quote("#define STR_GPS_DELAYCREATION              L\"GPS_DELAYCREATION\"")
cpp_quote("#define STR_GPS_BESTEFFORT                 L\"GPS_BESTEFFORT\"")
cpp_quote("#define STR_GPS_NO_OPLOCK                  L\"GPS_NO_OPLOCK\"")

// Shell Namespace helper 2
[
    uuid(7e9fb0d3-919f-4307-ab2e-9b1860310c93),
    object,
    pointer_default(unique)
]
interface IShellItem2 : IShellItem
{
    HRESULT GetPropertyStore(
        [in] GETPROPERTYSTOREFLAGS flags,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetPropertyStoreWithCreateObject(
        [in] GETPROPERTYSTOREFLAGS flags,
        [in] IUnknown *punkCreateObject,   // factory for low-rights creation of type ICreateObject
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetPropertyStoreForKeys(
        [in, size_is(cKeys)] const PROPERTYKEY *rgKeys,
        [in] UINT cKeys,
        [in] GETPROPERTYSTOREFLAGS flags,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetPropertyDescriptionList(
        [in] REFPROPERTYKEY keyType,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    // Ensures any cached information in this item is up to date, or returns __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) if the item does not exist.
    HRESULT Update([in, unique] IBindCtx *pbc);

    HRESULT GetProperty(
        [in] REFPROPERTYKEY key,
        [out] PROPVARIANT *ppropvar);

    HRESULT GetCLSID(
        [in] REFPROPERTYKEY key,
        [out] CLSID *pclsid);

    HRESULT GetFileTime(
        [in] REFPROPERTYKEY key,
        [out] FILETIME *pft);

    HRESULT GetInt32(
        [in] REFPROPERTYKEY key,
        [out] int *pi);

    HRESULT GetString(
        [in] REFPROPERTYKEY key,
        [out, string] LPWSTR *ppsz);

    HRESULT GetUInt32(
        [in] REFPROPERTYKEY key,
        [out] ULONG *pui);

    HRESULT GetUInt64(
        [in] REFPROPERTYKEY key,
        [out] ULONGLONG *pull);

    HRESULT GetBool(
        [in] REFPROPERTYKEY key,
        [out] BOOL *pf);
}
//cpp_quote("#endif  // NTDDI_VISTA")

[v1_enum] enum _SIIGBF
{
    SIIGBF_RESIZETOFIT   = 0x00000000,   // if necessary, stretch down the bitmap (preserving aspect ratio) so width and height fit size given; width or height or both may be smaller if natural size is smaller
    SIIGBF_BIGGERSIZEOK  = 0x00000001,   // a larger bitmap than requested may be returned, the caller will manage scaling down (inverse of SIIGBF_RESIZETOFIT)
    SIIGBF_MEMORYONLY    = 0x00000002,   // do not hit the disk, even if cached
    SIIGBF_ICONONLY      = 0x00000004,   // return only the icon, never the thumbnail
    SIIGBF_THUMBNAILONLY = 0x00000008,   // return only the thumbnail, never the icon
    SIIGBF_INCACHEONLY   = 0x00000010,   // ok to touch the disk, but only to retrieve an already cached item
};
typedef int SIIGBF;


[
    uuid(bcc18b79-ba16-442f-80c4-8a59c30c463b),
    object,
    pointer_default(unique)
]
interface IShellItemImageFactory : IUnknown
{
    // bitmap returned is a DIB; color format is RGB24, RGB32 or PARGB32
    HRESULT GetImage(
        [in] SIZE size,
        [in] SIIGBF flags,
        [out] HBITMAP *phbm);
}

// Notification callback for changes to user accounts
[
    object,
    uuid(a561e69a-b4b8-4113-91a5-64c6bcca3430),
    version(1.0)
]
interface IUserAccountChangeCallback : IUnknown
{
    HRESULT OnPictureChange(
        [in, string] LPCWSTR pszUserName);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

// Shell Namespace enumerator
[
    uuid(70629033-e363-4a28-a567-0db78006e6d7),
    object,
    pointer_default(unique)
]
interface IEnumShellItems : IUnknown
{
    [local]
    HRESULT Next(
        [in, annotation("__in")] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched), annotation("__out_ecount_part(celt, *pceltFetched)")] IShellItem **rgelt,
        [out, annotation("__out_opt __deref_out_range(0, celt)")] ULONG *pceltFetched);

    [call_as(Next)]
    HRESULT RemoteNext(
        [in] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched)] IShellItem **rgelt,
        [out] ULONG *pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumShellItems **ppenum);
}

typedef GUID STGTRANSCONFIRMATION, *LPSTGTRANSCONFIRMATION;

// Storage operations

typedef [v1_enum] enum STGOP
{
    STGOP_MOVE               = 1,
    STGOP_COPY               = 2,
    STGOP_SYNC               = 3,
    STGOP_REMOVE             = 5,
    STGOP_RENAME             = 6,
    STGOP_APPLYPROPERTIES    = 8,   // _WIN32_WINNT >= 0x0600
    STGOP_NEW                = 10,  // _WIN32_WINNT >= 0x0600
} STGOP;

cpp_quote("#endif  // NTDDI_WINXP")

// ITransferSource/ITransferDestination flag values use for OpenItem/MoveItem/RecycleItem/RemoveItem/etc

[v1_enum] enum _TRANSFER_SOURCE_FLAGS
{
    TSF_NORMAL                      = 0x0000,
    TSF_FAIL_EXIST                  = 0x0000,   // Fail if destination already exists
    TSF_RENAME_EXIST                = 0x0001,   // Rename with auto-name generation if destination already exists
    TSF_OVERWRITE_EXIST             = 0x0002,   // Overwrite/Merge with destination
    TSF_ALLOW_DECRYPTION            = 0x0004,   // Allow creation of decrypted destination
    TSF_NO_SECURITY                 = 0x0008,   // Without DACL/SACL/Owner
    TSF_COPY_CREATION_TIME          = 0x0010,   // Copy the creation time as part of the copy (useful for move as copy/delete)
    TSF_COPY_WRITE_TIME             = 0x0020,   // Copy the last write time as part of the copy
    TSF_USE_FULL_ACCESS             = 0x0040,   // Open a file with write, read, or delete as share mode
    TSF_DELETE_RECYCLE_IF_POSSIBLE  = 0x0080,   // Recycle if possible
    TSF_COPY_HARD_LINK              = 0x0100,   // Hard link desired (not required)
    TSF_COPY_LOCALIZED_NAME         = 0x0200,   // Copy localized name
    TSF_MOVE_AS_COPY_DELETE         = 0x0400,   // We are doing a move operation, but we are doing it as a copy/delete
    TSF_SUSPEND_SHELLEVENTS         = 0x0800,   // suspend shell events
};
typedef DWORD TRANSFER_SOURCE_FLAGS;

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

[
    uuid(d594d0d8-8da7-457b-b3b4-ce5dbaac0b88),
    pointer_default(unique),
    local
]
interface ITransferAdviseSink : IUnknown
{
    [v1_enum] enum _TRANSFER_ADVISE_STATE
    {
        TS_NONE            = 0x00000000,
        TS_PERFORMING      = 0x00000001,       // Transfer is being performed
        TS_PREPARING       = 0x00000002,       // Preparing to perform transfer - calculating space needed, etc.
        TS_INDETERMINATE   = 0x00000004,       // The length of the transfer is indeterminate
    };
    typedef DWORD TRANSFER_ADVISE_STATE;

    //  UpdateProgress
    //
    //      Updates the sink as to current progress of an operation.
    //
    //      Implementers of this function should return an error code when the operation needs to terminate early (e.g. the user clicked on the cancel button).
    //      If all parameters are 0, UpdateProgress should not change any of its progress data but should can still return an error code
    //      to halt the operation.
    //      If all the total parameters are 0 but some of the current parameters are non-zero, UpdateProgress should update it's current progress but shouldn't change
    //      it's total progress.
    //
    //      Callers should regularly query for a cancel request by calling this function with all parameters set to 0 even if no measurable progress occured.
    //
    //  Parameters:
    //
    //      ullSizeTotal, nFilesTotal, nFoldersTotal
    //          Total size in bytes, number of files and number of folders. This includes what has been processed and what will be processed.
    //          Setting all three to 0 indicates that the totals have not changed since the last call to UpdateProgress.
    //
    //      ullSizeCurrent, nFilesCurrent, nFoldersCurrent
    //          Number of bytes, files and folders processed since the start of the operation.
    //          Setting all six parameters to zero indicates that progress has not changed since the last call to UpdateProgress.
    //
    //  Return values:
    //      COPYENGINE_E_USER_CANCELLED
    //          The user has cancelled the operation and the caller should halt execution of the operation as soon as possible.
    //
    //      Any other error:
    //          The caller should halt execution of the operation as soon as possible.
    HRESULT UpdateProgress(
        [in, annotation("__in")] ULONGLONG ullSizeCurrent,
        [in, annotation("__in")] ULONGLONG ullSizeTotal,
        [in, annotation("__in")] int nFilesCurrent,
        [in, annotation("__in")] int nFilesTotal,
        [in, annotation("__in")] int nFoldersCurrent,
        [in, annotation("__in")] int nFoldersTotal);

    HRESULT UpdateTransferState([in, annotation("__in")] TRANSFER_ADVISE_STATE ts);

    //  ConfirmOverwrite
    //
    //  Parameters:
    //      psiSource
    //          Source IShellItem.
    //      psiDestParent
    //          Destination's parent folder's IShellItem.
    //      pszName
    //          Pointer to wide-string containing the name of the item. If NULL,
    //          the name is the same as the psiSource's.
    //
    //  Return Values from Confirmations
    //      COPYENGINE_S_USER_IGNORED
    //          Continue operation
    //      COPYENGINE_E_USER_CANCELLED
    //          is a user-interaction cancel. The user clicked "Cancel" somewhere.
    //
    //      Any other HRESULT should be passed up.

    // Confirm that the operation is ok to actually overwrite an existing item
    HRESULT ConfirmOverwrite(
        [in, annotation("__in")] IShellItem *psiSource,
        [in, annotation("__in")] IShellItem *psiDestParent,
        [in, string, annotation("__in")] LPCWSTR pszName);

    // Confirm that the operation is ok to lose encryption (disclosure)
    HRESULT ConfirmEncryptionLoss([in, annotation("__in")] IShellItem *psiSource);

    //  Parameters:
    //      psi
    //          The IShellItem that is reporting the failure.
    //      pszItem
    //          If NULL, the "psi"'s display name will be used.
    //          If not NULL, this should be a pointer to a string that is the
    //          name of the item.
    //      hrError
    //          The error that is being reported.
    //      pszRename
    //          A buffer that the caller passes if it wants to be able to
    //          retry the operation with a new destination name. If this
    //          parameter is NULL, no option to rename will be available.
    //      cchRename
    //          Size of the buffer pointed to be pszRename.
    //
    //  Return Values:
    //      COPYENGINE_S_USER_RETRY
    //          The handler should retry the file operation.
    //      COPYENGINE_S_USER_IGNORED
    //          The handler should skip creating the item and return this code
    //          back to the copy engine.
    //      COPYENGINE_E_USERCANCELLED
    //          The user clicked "Cancel" somewhere. The entire copy job is
    //          being aborted. The handler should return this code back to the
    //          copy engine.
    //
    //      Any other HRESULT should be passed up. If failure not handled,
    //      the return value should be the same as hrError.
    HRESULT FileFailure(
        [in, annotation("__in")] IShellItem *psi,
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszItem,
        [in, annotation("__in")] HRESULT hrError,
        [out, unique, size_is(cchRename), annotation("__out_ecount_opt(cchRename)")] LPWSTR pszRename,
        [in, annotation("__in")] ULONG cchRename);

    HRESULT SubStreamFailure(
        [in, annotation("__in")] IShellItem *psi,
        [in, string, annotation("__in")] LPCWSTR pszStreamName,
        [in, annotation("__in")] HRESULT hrError);

    HRESULT PropertyFailure(
        [in, annotation("__in")] IShellItem *psi,
        [in, unique, annotation("__in_opt")] const PROPERTYKEY* pkey,   // (pkey == NULL) indicates loss of all properties
        [in, annotation("__in")] HRESULT hrError);
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

[
    object,
    uuid(00adb003-bde9-45c6-8e29-d09f9353e108),
    pointer_default(unique),
    local
]
interface ITransferSource : IUnknown
{
    //  Description:
    //      Do an advise before calling anything so the handler can callback for
    //      any errors that might occur. If not set, the handler should consider
    //      it an indication that no feedback is available and to do the "default"
    //      operation.
    //
    //  Parameters:
    //      psink
    //          ITransferAdviseSink interface to be used for status and
    //          failures.
    //      pdwCookie
    //          Pointer to a returned token that uniquely identifies this
    //          connection. The caller uses this token later to delete the
    //          connection by passing it to the Unadvise method. If the
    //          connection was not successfully established, this value is zero.
    //
    //  Return Values:
    //      S_OK
    //          Interface successfully associated.
    //      E_UNEXPECTED
    //          The handler can only handle one sink interface.
    //
    //      other HRESULTs indicate a failure.
    HRESULT Advise(
        [in, annotation("__in")] ITransferAdviseSink *psink,
        [out, annotation("__out")] DWORD *pdwCookie);

    //  Description:
    //      Terminates an advisory connection previously established through
    //      Advise method. The dwCookie parameter identifies the connection
    //      to terminate
    //
    //  Parameters:
    //      dwCookie
    //          Connection token previously returned from Advise.
    //
    //  Return Values:
    //      S_OK
    //          The connection was successfully terminated.
    //      CONNECT_E_NOCONNECTION
    //          The value in dwCookie does not represent a valid connection.
    //
    //      other HRESULTs indicate a failure.
    HRESULT Unadvise([in, annotation("__in")] DWORD dwCookie);

    //  Description:
    //      Set properties that should be applied to an item
    //
    //  Parameters:
    //      pproparray
    //          Contains a list of changes
    //
    //  Return Values:
    //      S_OK
    //          Properties set successfully
    //      other HRESULTs indicate a failure.
    HRESULT SetProperties([in, annotation("__in")] IPropertyChangeArray *pproparray);

    // Open the item for copying, returning an object that can be enumerated
    // for resources (IShellItemResources).
    HRESULT OpenItem(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] TRANSFER_SOURCE_FLAGS flags,
        [in, annotation("__in")] REFIID riid,
        [out, iid_is(riid), annotation("__deref_out")] void **ppv);

    // Move the item within the volume/namespace, returning the shell item
    // in its new location.
    // returns:
    //      FAILED() codes with special meaning for
    //          HRESULT_FROM_WIN32(ERROR_NOT_SAME_DEVICE) -> caller should convert move into a copy/delete
    //          E_NOINTERFACE -> caller should convert move into a copy/delete
    //          in the case of moving a folder
    //              HRESULT_FROM_WIN32(ERROR_FILE_EXISTS) or HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)
    //              indicates 
    //          to convert to a copy/delete the destination item must support ITransferDestination
    //
    //      SUCCEEDED() code with special meaning for
    //          S_OK - move succeeded, *ppsiNew contains the new item that is the target of the move
    //          COPYENGINE_S_USER_IGNORED -> *ppsiNew is NULL, the destination item already exists and
    //              has not been overwritten. caller should complete the "move" by deleting the
    ///             source item
    //          COPYENGINE_S_MERGE -> *ppsiNew is NULL, the destination folder already exists
    //              and the user has chosen to proceed merging the folder, the caller should complete
    //              the "move" of the folder by deleting the source

    HRESULT MoveItem(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] IShellItem *psiParentDst,
        [in, string, annotation("__in")] LPCWSTR pszNameDst,
        [in] TRANSFER_SOURCE_FLAGS flags,
        [out, annotation("__deref_out")] IShellItem **ppsiNew);

    // Recycle the item into the provided recycle location, returning the new
    // recycled item in that location.
    HRESULT RecycleItem(
        [in, annotation("__in")] IShellItem *psiSource,
        [in, annotation("__in")] IShellItem *psiParentDest,
        [in, annotation("__in")] TRANSFER_SOURCE_FLAGS flags,
        [out, annotation("__deref_out")] IShellItem **ppsiNewDest);

    // Removed the item (without recycle support)
    HRESULT RemoveItem(
        [in, annotation("__in")] IShellItem *psiSource,
        [in, annotation("__in")] TRANSFER_SOURCE_FLAGS flags);

    // Change the name of an item, returing the shell item in its new location
    HRESULT RenameItem(
        [in, annotation("__in")] IShellItem *psiSource,
        [in, string, annotation("__in")] LPCWSTR pszNewName,
        [in, annotation("__in")] TRANSFER_SOURCE_FLAGS flags,
        [out, annotation("__deref_out")] IShellItem **ppsiNewDest);

    // not used or supported, return E_NOTIMPL
    HRESULT LinkItem(
        [in, annotation("__in")] IShellItem *psiSource,
        [in, annotation("__in")] IShellItem *psiParentDest,
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszNewName,
        [in, annotation("__in")] TRANSFER_SOURCE_FLAGS flags,
        [out, annotation("__deref_out")] IShellItem **ppsiNewDest);

    // Apply a set of property changes to an item, return the modified shell item.
    HRESULT ApplyPropertiesToItem(
        [in, annotation("__in")] IShellItem *psiSource,
        [out, annotation("__deref_out")] IShellItem **ppsiNew);

    // Return the default name, if different from the items parsing name.
    HRESULT GetDefaultDestinationName(
        [in, annotation("__in")] IShellItem *psiSource,
        [in, annotation("__in")] IShellItem *psiParentDest,
        [out, string, annotation("__deref_out")] LPWSTR *ppszDestinationName);

    //  Description:
    //      These are called after a destination folder item has been created.
    //      EnterFolder() will be called before the children objects will be
    //      created.
    //
    //      Expected the order of operations to be:
    //      DoCopyItem( psiParentSource, psiParentFolderDest, pszChildName )
    //      {
    //          psiParentSource->BindToHandler( ..., &ptsParentFolderSource)
    //          ptsParentSource->Advise( psink, &dwCookie )
    //          ptsParentSource->CopyItem( psiParentFolderDest, pszChildName, 0, &psiFolderDest )
    //          if ( psiParentSource.HasChildren() )
    //          {
    //              ptsParentSource->EnterFolder( psiFolderDest )
    //              for each child in psiParentSource
    //              {
    //                  psiParentSource->"GetChild"( &psiChildSource ); <-- a little more complicated
    //                  DoCopyItem( psiChildSource , psiFolderDest )
    //              }
    //              ptsParentSource->LeaveFolder( psiFolderDest )
    //          }
    //          ptsParentSource->Unadvise( dwCookie )
    //      }
    //
    //  Parameters:
    //      psiChildFolderDest
    //          IShellItem of the folder being entered.
    //
    //  Return Values:
    //      S_OK
    //          Operation successful.
    //
    //      other HRESULTs indicate failure.
    HRESULT EnterFolder([in, annotation("__in")] IShellItem *psiChildFolderDest);

    HRESULT LeaveFolder([in, annotation("__in")] IShellItem *psiChildFolderDest);
}

cpp_quote("#endif  // _WIN32_IE_IE70")

typedef struct SHELL_ITEM_RESOURCE
{
    GUID    guidType;
    WCHAR   szName[260 /*MAX_PATH*/];
} SHELL_ITEM_RESOURCE;

[
    object,
    uuid(2dd81fe3-a83c-4da9-a330-47249d345ba1),
    pointer_default(unique)
]
interface IEnumResources : IUnknown
{
    HRESULT Next(
        [in] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched)] SHELL_ITEM_RESOURCE *psir,
        [out] ULONG *pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumResources **ppenumr);
}

[
    object,
    uuid(ff5693be-2ce0-4d48-b5c5-40817d1acdb9),
    pointer_default(unique)
]
interface IShellItemResources : IUnknown
{
    HRESULT GetAttributes([out] DWORD *pdwAttributes);

    HRESULT GetSize([out] ULONGLONG *pullSize);

    HRESULT GetTimes(
        [out] FILETIME *pftCreation,
        [out] FILETIME *pftWrite,
        [out] FILETIME *pftAccess);

    HRESULT SetTimes(
        [in, unique] const FILETIME *pftCreation,
        [in, unique] const FILETIME *pftWrite,
        [in, unique] const FILETIME *pftAccess);

    HRESULT GetResourceDescription(
        [in] const SHELL_ITEM_RESOURCE *pcsir,
        [out, string] LPWSTR *ppszDescription);

    HRESULT EnumResources([out] IEnumResources **ppenumr);

    HRESULT SupportsResource([in] const SHELL_ITEM_RESOURCE *pcsir);

    HRESULT OpenResource(
        [in] const SHELL_ITEM_RESOURCE *pcsir,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT CreateResource(
        [in] const SHELL_ITEM_RESOURCE *pcsir,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT MarkForDelete();
}

[
    object,
    uuid(48addd32-3ca5-4124-abe3-b5a72531b207),
    pointer_default(unique),
    local
]
interface ITransferDestination : IUnknown
{
    //  *** 1: advise ***

    //  Do an advise before calling anything so the object can callback for
    //  any errors that might occur. If not set, the object should consider
    //  it an indication that no feedback is available and to do the "default"
    //  for the operation.
    HRESULT Advise(
        [in, annotation("__in")] ITransferAdviseSink * psink,
        [out, annotation("__out")] DWORD * pdwCookie);

    HRESULT Unadvise([in] DWORD dwCookie);

    // returns:
    //      SUCCEEDED() code with special meaning for
    //          S_OK - move succeeded, *ppvItem and *ppvResources contains the new item and resources object
    //          that should be copied to
    //          COPYENGINE_S_USER_IGNORED ->  *ppvItem and *ppvResources are NULL, the destination item already exists and
    //              has not been overwritten. if the caller is implemeting "move" as copy/delete it should complete 
    //              the "move" by deleting the source item

    HRESULT CreateItem(
        [in, string, annotation("__in")] LPCWSTR pszName,
        // FILE_ATTRIBUTE_XXX values, most important being FILE_ATTRIBUTE_DIRECTORY indicating that
        // a folder should be created
        [in, annotation("__in")] DWORD dwAttributes,
        // the size of the item being copied or zero if unknow
        [in, annotation("__in")] ULONGLONG ullSize,
        [in, annotation("__in")] TRANSFER_SOURCE_FLAGS flags, 
        // ppvItem should be an IShellItem or derived interface
        [in, annotation("__in")] REFIID riidItem,
        [out, iid_is(riidItem), annotation("__deref_out")] void **ppvItem,
        // ppvResources should be an IShellItemResources or derived interface
        [in, annotation("__in")] REFIID riidResources,
        [out, iid_is(riidResources), annotation("__deref_out")] void **ppvResources);
}

// This structure is defined in winbase.h or winternl.h which is not visible to idl files,
// so we redeclare it here.

cpp_quote("#ifdef MIDL_PASS")

typedef struct _OVERLAPPED {
    ULONG_PTR Internal;
    ULONG_PTR InternalHigh;
    union {
        struct {
            DWORD Offset;
            DWORD OffsetHigh;
        };

        PVOID Pointer;
    };

    HANDLE  hEvent;
} OVERLAPPED, *LPOVERLAPPED;

cpp_quote("#endif // MIDL_PASS")

[
    object,
    uuid(fe0b6665-e0ca-49b9-a178-2b5cb48d92a5),
    pointer_default(unique),
    local
]
interface IStreamAsync : IStream
{
    HRESULT ReadAsync([out, size_is(cb), length_is(*pcbRead), annotation("__out_bcount_part(cb, *pcbRead)")] void *pv, [in] DWORD cb, [out, annotation("__out_opt __deref_out_range(0, cb)")] LPDWORD pcbRead, [in, annotation("__in")] LPOVERLAPPED lpOverlapped);
    HRESULT WriteAsync([in, size_is(cb), annotation("__in_bcount(cb)")] void const *lpBuffer, [in] DWORD cb, [out, annotation("__out_opt __deref_out_range(0, cb)")] LPDWORD pcbWritten, [in, annotation("__in")] LPOVERLAPPED lpOverlapped);
    HRESULT OverlappedResult([in, annotation("__in")] LPOVERLAPPED lpOverlapped, [out, annotation("__out")] LPDWORD lpNumberOfBytesTransferred, [in, annotation("__in")] BOOL bWait);
    HRESULT CancelIo();
}

[
    object,
    uuid(8a68fdda-1fdc-4c20-8ceb-416643b5a625),
    pointer_default(unique),
    local
]
interface IStreamUnbufferedInfo : IUnknown
{
    HRESULT GetSectorSize([out, annotation("__out")] ULONG *pcbSectorSize);
}

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

[
    object,
    uuid(04b0f1a7-9490-44bc-96e1-4296a31252e2),
    pointer_default(unique),
]
interface IFileOperationProgressSink : IUnknown
{
    HRESULT StartOperations();

    HRESULT FinishOperations(
        [in] HRESULT hrResult);

    HRESULT PreRenameItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in, unique, string] LPCWSTR pszNewName);

    HRESULT PostRenameItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in, string] LPCWSTR pszNewName,
        [in] HRESULT hrRename,
        [in] IShellItem *psiNewlyCreated);

    HRESULT PreMoveItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName);

    HRESULT PostMoveItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName,
        [in] HRESULT hrMove,
        [in] IShellItem *psiNewlyCreated);

    HRESULT PreCopyItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName);

    HRESULT PostCopyItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName,
        [in] HRESULT hrCopy,
        [in] IShellItem *psiNewlyCreated);

    HRESULT PreDeleteItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem);

    HRESULT PostDeleteItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiItem,
        [in] HRESULT hrDelete,
        [in] IShellItem *psiNewlyCreated);

    HRESULT PreNewItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName);

    HRESULT PostNewItem(
        [in] DWORD dwFlags,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName,
        [in, unique, string] LPCWSTR pszTemplateName,
        [in] DWORD dwFileAttributes,
        [in] HRESULT hrNew,
        [in] IShellItem *psiNewItem);

    HRESULT UpdateProgress(
        [in] UINT iWorkTotal,
        [in] UINT iWorkSoFar);

    HRESULT ResetTimer();

    HRESULT PauseTimer();

    HRESULT ResumeTimer();
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
// Shell Item Container
[
    uuid(b63ea76d-1f85-456f-a19c-48159efa858b),
    object,
    pointer_default(unique)
]
interface IShellItemArray : IUnknown
{
    typedef [v1_enum] enum SIATTRIBFLAGS
    {
        SIATTRIBFLAGS_AND               = 0x00000001, // if multiple items and the attirbutes together.
        SIATTRIBFLAGS_OR                = 0x00000002, // if multiple items or the attributes together.
        SIATTRIBFLAGS_APPCOMPAT         = 0x00000003, // Call GetAttributes directly on the ShellFolder for multiple attributes
        SIATTRIBFLAGS_MASK              = 0x00000003, // for the AND/OR/APPCOMPAT value
        SIATTRIBFLAGS_ALLITEMS          = 0x00004000, // normally only the first few items are used to compute the attributes, pass this to force all of them
                                                      // doing all will result in poor performance for large arrays so use this carefuly
    } SIATTRIBFLAGS;
    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(SIATTRIBFLAGS)")  // some bits are flags, others are not

    // bhid values supported for the handler type are defined in shlguid.h
    // BHID_DataObject - IDataObject, only works for flat data objects or item arrays produced directly using SHCreateShellItemArrayFromDataObject()
    // BHID_AssociationArray - IQueryAssociations from the first item in the array
    // BHID_SFUIObject - only works for flat (items in the same folder) item array
    HRESULT BindToHandler([in, unique] IBindCtx *pbc, [in] REFGUID bhid, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut);

    HRESULT GetPropertyStore([in] GETPROPERTYSTOREFLAGS flags, [in] REFIID riid, [out, iid_is(riid)] void **ppv);

    HRESULT GetPropertyDescriptionList([in] REFPROPERTYKEY keyType, [in] REFIID riid, [out, iid_is(riid)] void **ppv);

    // get the attributes for the items using different methods defined by SIATTRIBFLAGS
    HRESULT GetAttributes([in] SIATTRIBFLAGS AttribFlags, [in] SFGAOF sfgaoMask, [out] SFGAOF *psfgaoAttribs);

    HRESULT GetCount([out] DWORD *pdwNumItems);

    HRESULT GetItemAt([in] DWORD dwIndex, [out] IShellItem **ppsi);

    HRESULT EnumItems([out] IEnumShellItems **ppenumShellItems);
}
//cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("SHSTDAPI SHCreateShellItemArray(__in_opt PCIDLIST_ABSOLUTE pidlParent, __in_opt IShellFolder *psf, __in UINT cidl, __in_ecount_opt(cidl) PCUITEMID_CHILD_ARRAY ppidl, __deref_out IShellItemArray **ppsiItemArray);")
cpp_quote("SHSTDAPI SHCreateShellItemArrayFromDataObject(__in IDataObject *pdo, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("SHSTDAPI SHCreateShellItemArrayFromIDLists(__in UINT cidl, __in_ecount(cidl) PCIDLIST_ABSOLUTE_ARRAY rgpidl, __deref_out IShellItemArray **ppsiItemArray);")
cpp_quote("SHSTDAPI SHCreateShellItemArrayFromShellItem(__in IShellItem *psi, __in REFIID riid, __deref_out void **ppv);")
cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

[
    uuid(7f73be3f-fb79-493c-a6c7-7ee14e245841),
    object,
    pointer_default(unique)
]
interface IInitializeWithItem : IUnknown
{
    // grfMode is STGM_ values indicating read/readwrite and sharing modes
    HRESULT Initialize([in] IShellItem *psi, [in] DWORD grfMode);
}

[
    object,
    uuid(1c9cd5bb-98e9-4491-a60f-31aacc72b83c),
    pointer_default(unique)
]
interface IObjectWithSelection : IUnknown
{
    HRESULT SetSelection([in] IShellItemArray *psia);

    HRESULT GetSelection(
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);
}

[
    object,
    uuid(321a6a6a-d61f-4bf3-97ae-14be2986bb36),
    pointer_default(unique)
]
interface IObjectWithBackReferences : IUnknown
{
    // This method is used for all tasks associated with freeing/releasing back references held
    // by an object, and may prepare an object for reuse
    HRESULT RemoveBackReferences();
}

[v1_enum] enum _PROPERTYUI_NAME_FLAGS
{
    PUIFNF_DEFAULT          = 0x00000000,
    PUIFNF_MNEMONIC         = 0x00000001,   // include mnemonic in display name
};
typedef DWORD PROPERTYUI_NAME_FLAGS;

[v1_enum] enum _PROPERTYUI_FLAGS
{
    PUIF_DEFAULT                 = 0x00000000,
    PUIF_RIGHTALIGN              = 0x00000001,   // this property should be right aligned
    PUIF_NOLABELININFOTIP        = 0x00000002,   // this property should not display a label in the infotip
};
typedef DWORD PROPERTYUI_FLAGS;

[v1_enum] enum _PROPERTYUI_FORMAT_FLAGS
{
    PUIFFDF_DEFAULT         = 0x00000000,
    PUIFFDF_RIGHTTOLEFT     = 0x00000001,   // deprecated - do not use
    PUIFFDF_SHORTFORMAT     = 0x00000002,   // short format version of string
    PUIFFDF_NOTIME          = 0x00000004,   // truncate time to days, not hours/mins/sec
    PUIFFDF_FRIENDLYDATE    = 0x00000008,   // "Today", "Yesterday", etc
};
typedef DWORD PROPERTYUI_FORMAT_FLAGS;

// helper service for dealing with properties ala IPropertySetStorage
[
    uuid(757a7d9f-919a-4118-99d7-dbb208c8cc66),
    object,
    pointer_default(unique)
]
interface IPropertyUI : IUnknown
{
    HRESULT ParsePropertyName(
        [in, string] LPCWSTR pszName,
        [out] FMTID *pfmtid,
        [out] PROPID *ppid,
        [in, out] ULONG *pchEaten);

    HRESULT GetCannonicalName(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [out, string, size_is(cchText)] LPWSTR pwszText,
        [in] DWORD cchText);

    HRESULT GetDisplayName(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [in] PROPERTYUI_NAME_FLAGS flags,
        [out, size_is(cchText)] LPWSTR pwszText,
        [in] DWORD cchText);

    HRESULT GetPropertyDescription(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [out, size_is(cchText)] LPWSTR pwszText,
        [in] DWORD cchText);

    HRESULT GetDefaultWidth(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [out] ULONG *pcxChars);

    HRESULT GetFlags(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [out] PROPERTYUI_FLAGS *pflags);

    HRESULT FormatForDisplay(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [in] const PROPVARIANT *ppropvar,
        [in] PROPERTYUI_FORMAT_FLAGS puiff,
        [out, string, size_is(cchText)] LPWSTR pwszText,
        [in] DWORD cchText);

    HRESULT GetHelpInfo(
        [in] REFFMTID fmtid,
        [in] PROPID pid,
        [out, string, size_is(cch)] LPWSTR pwszHelpFile,
        [in] DWORD cch,
        [out] UINT *puHelpID);
}

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("SHSTDAPI SHRemovePersonalPropertyValues(__in IShellItemArray *psia);")
cpp_quote("SHSTDAPI SHAddDefaultPropertiesByExt(PCWSTR pszExt, IPropertyStore *pPropStore);")
cpp_quote("SHSTDAPI SHCreateDefaultPropertiesOp(IShellItem *psi, __out IFileOperation **ppFileOp);")
cpp_quote("SHSTDAPI SHSetDefaultProperties(__in_opt HWND hwnd, IShellItem *psi, DWORD dwFileOpFlags, __in_opt IFileOperationProgressSink *pfops);")
cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

//-------------------------------------------------------------
// Folder Category Support
//-------------------------------------------------------------
cpp_quote("#if (_WIN32_IE >= 0x0500)")

// Provides a list of catagorizers registered on an IShellFolder
[
    uuid(9af64809-5864-4c26-a720-c1f78c086ee3),
    object,
    pointer_default(unique)
]
interface ICategoryProvider : IUnknown
{
    // Returns S_OK if the view should display this column in category selection UI, or S_FALSE to remove it.
    HRESULT CanCategorizeOnSCID([in] const SHCOLUMNID* pscid);

    // Returns either a GUID to create in CreateCategory, or a SHCOLUNNID that is used by the default categorizer. 
    // Return S_FALSE if you do not support a default group.
    // GUID_NULL returned in pguid indicates to the client to use pscid as the default category.
    HRESULT GetDefaultCategory(
        [out] GUID* pguid,
        [out] SHCOLUMNID* pscid);

    // Returns either a GUID that represents the categoizer to use for the specified SHCOLUMNID.
    HRESULT GetCategoryForSCID(
        [in] const SHCOLUMNID* pscid,
        [out] GUID* pguid);

    // Returns an IEnumGUID that has a list of GUIDs that represent categories.
    HRESULT EnumCategories([out] IEnumGUID** penum);

    // Returns the name of the given category.
    HRESULT GetCategoryName(
        [in] const GUID* pguid,
        [out, string, size_is(cch)] LPWSTR pszName,
        [in] UINT cch);

    // Creates the category.
    HRESULT CreateCategory(
        [in] const GUID* pguid,
        [in] REFIID riid,
        [out, iid_is(riid)] void** ppv);
}

typedef [v1_enum] enum CATEGORYINFO_FLAGS
{
    CATINFO_NORMAL            = 0x00000000,   // Apply default properties to this category
    CATINFO_COLLAPSED         = 0x00000001,   // This category should appear collapsed. useful for the "None" category.
    CATINFO_HIDDEN            = 0x00000002,   // This category should follow the "Hidden" files setting for being displayed
    CATINFO_EXPANDED          = 0x00000004,   // This category should appear expanded.
    CATINFO_NOHEADER          = 0x00000008,   // This category has no header.
    CATINFO_NOTCOLLAPSIBLE    = 0x00000010,   // This category can not be collapsed.
    CATINFO_NOHEADERCOUNT     = 0x00000020,   // The count of items in the category should not be displayed in the header
    // Win7 Flags
    CATINFO_SUBSETTED         = 0x00000040,   // The category should appear subsetted.
} CATEGORYINFO_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(CATEGORYINFO_FLAGS)")

typedef [v1_enum] enum CATSORT_FLAGS
{
    CATSORT_DEFAULT     = 0x00000000,   // Default Sort order
    CATSORT_NAME        = 0x00000001,   // Sort by name
} CATSORT_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(CATSORT_FLAGS)")

typedef struct CATEGORY_INFO
{
    CATEGORYINFO_FLAGS cif;
    WCHAR wszName[260];
} CATEGORY_INFO;

//-------------------------------------------------------------
// ICategorizer
//-------------------------------------------------------------

// Categorizes items
[
    uuid(a3b14589-9174-49a8-89a3-06a1ae2b9ba7),
    object,
    pointer_default(unique)
]
interface ICategorizer : IUnknown
{
    // Returns the description of this category that will be displayed in the UI
    HRESULT GetDescription(
        [out, string, size_is(cch)] LPWSTR pszDesc,
        [in] UINT cch);

    // Returns a list of categories associated with a list of ID Lists. NOTE: -1 is an invalid Category ID, and they cannot be persisted
    HRESULT GetCategory(
        [in] UINT cidl,
        [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl,
        [out, size_is(cidl)] DWORD* rgCategoryIds);

    // Returns information about the category, such as default display and the text to display in the UI
    HRESULT GetCategoryInfo(
        [in] DWORD dwCategoryId,
        [out] CATEGORY_INFO* pci);

    // Returns HRESULTFromShort. -1, 0, 1 indicate the comparison of the IDs. Used for sorting categories in the UI
    HRESULT CompareCategory(
        [in] CATSORT_FLAGS csfFlags,
        [in] DWORD dwCategoryId1,
        [in] DWORD dwCategoryId2);
}

cpp_quote("#endif // (_WIN32_IE >= 0x0500)")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN2K)")

///////////////////////////////////////////////////////
//
// Drag and Drop helper
//
// Purpose: To expose the Shell drag images
//
// This interface is implemented in the shell by CLSID_DragDropHelper.
//
// To use:
//   If you are the source of a drag (i.e. in response to LV_DRAGBEGIN or
//    equivelent begin drag message) call
//    IDragSourceHelper::InitializeFromWindow
//              (<hwnd of window supporting DI_GETDRAGIMAGE>,
//               <pointer to POINT indicating offset to the mouse from
//                  the upper left corner of the image>,
//               <pointer to data object>)
//
//      NOTE: The Data object must support IDataObject::SetData with multiple
//            data types and GetData must implement data type cloning
//            (Including HGLOBAL), not just aliasing.
//
//   If you want to adjust the behavior of the drag image by calling
//    IDragSourceHelper2::SetFlags then that call to SetFlags should be
//    made before calling InitializeFromWindow or InitializeFromBitmap.
//
//   If you wish to have an image while over your application add the
//    IDragImages::Dr* calls to your IDropTarget implementation. For Example:
//
//    STDMETHODIMP CUserDropTarget::DragEnter(IDataObject* pDataObject,
//                                            DWORD grfKeyState,
//                                            POINTL pt, DWORD* pdwEffect)
//    {
//          // Process your DragEnter
//          // Call IDragImages::DragEnter last.
//          _pDropTargetHelper->DragEnter(_hwndDragOver, pDataObject,
//                                        (POINT*)&pt, *pdwEffect);
//          return hres;
//    }
//
//
//   If you wish to be able to source a drag image from a custom control,
//     implement a handler for the RegisterWindowMessage(DI_GETDRAGIMAGE).
//     The LPARAM is a pointer to an SHDRAGIMAGE structure.
//
//      sizeDragImage  -   Calculate the length and width required to render
//                          the images.
//      ptOffset       -   Calculate the offset from the upper left corner to
//                          the mouse cursor within the image
//      hbmpDragImage  -   CreateBitmap( sizeDragImage.cx, sizeDragImage.cy,
//                           GetDeviceCaps(hdcScreen, PLANES),
//                           GetDeviceCaps(hdcScreen, BITSPIXEL),
//                           NULL);
//
//   Drag Images will only be displayed on Windows NT 5.0 or later.
//
//
//   Note about IDropTargetHelper::Show - This method is provided for
//     showing/hiding the Drag image in low color depth video modes. When
//     painting to a window that is currently being dragged over (i.e. For
//     indicating a selection) you need to hide the drag image by calling this
//     method passing FALSE. After the window is done painting, Show the image
//     again by passing TRUE.

cpp_quote("#include <pshpack8.h>")
typedef struct SHDRAGIMAGE
{
    SIZE        sizeDragImage;      // OUT - The length and Width of the rendered image
    POINT       ptOffset;           // OUT - The Offset from the mouse cursor to the upper left corner of the image
    HBITMAP     hbmpDragImage;      // OUT - The Bitmap containing the rendered drag images
    COLORREF    crColorKey;         // OUT - The COLORREF that has been blitted to the background of the images
} SHDRAGIMAGE, *LPSHDRAGIMAGE;
cpp_quote("#include <poppack.h> // Return to byte packing")

// This is sent to a window to get the rendered images to a bitmap
// Call RegisterWindowMessage to get the ID
cpp_quote("#define DI_GETDRAGIMAGE     TEXT(\"ShellGetDragImage\")")

[
    uuid(4657278B-411B-11D2-839A-00C04FD918D0),
    local,
    pointer_default(unique)
]
interface IDropTargetHelper : IUnknown
{
    HRESULT DragEnter(
        [in, annotation("__in")] HWND hwndTarget,
        [in, annotation("__in")] IDataObject* pDataObject,
        [in, annotation("__in")] POINT* ppt,
        [in, annotation("__in")] DWORD dwEffect);

    HRESULT DragLeave();

    HRESULT DragOver(
        [in, annotation("__in")] POINT* ppt,
        [in, annotation("__in")] DWORD dwEffect);

    HRESULT Drop(
        [in, annotation("__in")] IDataObject* pDataObject,
        [in, annotation("__in")] POINT* ppt,
        [in, annotation("__in")] DWORD dwEffect);

    HRESULT Show([in, annotation("__in")] BOOL fShow);
}

[
    uuid(DE5BF786-477A-11D2-839D-00C04FD918D0),
    local,
    pointer_default(unique)
]
interface IDragSourceHelper: IUnknown
{
    // IDragSourceHelper
    HRESULT InitializeFromBitmap(
        [in, annotation("__in")] LPSHDRAGIMAGE pshdi,
        [in, annotation("__in")] IDataObject* pDataObject);

    HRESULT InitializeFromWindow(
        [in, unique, annotation("__in_opt")] HWND hwnd,
        [in, unique, annotation("__in_opt")] POINT* ppt,
        [in, annotation("__in")] IDataObject* pDataObject);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

// IDragSourceHelper2::SetFlags dwFlags
typedef [v1_enum] enum DSH_FLAGS
{
    DSH_ALLOWDROPDESCRIPTIONTEXT    = 0x0001,   // Allow text specified in DropDescription to be displayed on drag image
} DSH_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(DSH_FLAGS)")

[
    uuid(83E07D0D-0C5F-4163-BF1A-60B274051E40),
    local,
    pointer_default(unique)
]
interface IDragSourceHelper2 : IDragSourceHelper
{
    HRESULT SetFlags(
        [in, annotation("__in")] DWORD dwFlags);
}

cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#endif  // NTDDI_WIN2K")


cpp_quote("#ifdef UNICODE")
cpp_quote("#define IShellLink      IShellLinkW")
cpp_quote("#else")
cpp_quote("#define IShellLink      IShellLinkA")
cpp_quote("#endif")

// IShellLink::Resolve fFlags
typedef [v1_enum] enum SLR_FLAGS
{
    SLR_NO_UI                     = 0x0001,   // don't post any UI durring the resolve operation, not msgs are pumped
    SLR_ANY_MATCH                 = 0x0002,   // no longer used
    SLR_UPDATE                    = 0x0004,   // save the link back to it's file if the track made it dirty
    SLR_NOUPDATE                  = 0x0008,
    SLR_NOSEARCH                  = 0x0010,   // don't execute the search heuristics
    SLR_NOTRACK                   = 0x0020,   // don't use NT5 object ID to track the link
    SLR_NOLINKINFO                = 0x0040,   // don't use the net and volume relative info
    SLR_INVOKE_MSI                = 0x0080,   // if we have a darwin link, then call msi to fault in the applicaion
    SLR_NO_UI_WITH_MSG_PUMP       = 0x0101,   // SLR_NO_UI + requires an enable modeless site or HWND
    SLR_OFFER_DELETE_WITHOUT_FILE = 0x0200,   // offer the option to delete when unable to resolve, even if the shortcut is not file-backed
    SLR_KNOWNFOLDER               = 0x0400,   // report dirty if target is known folder and it got redirected -- 
                                              // this only works if orignal target was a file system path/ID list and not an aliased known folder ID list
    SLR_MACHINE_IN_LOCAL_TARGET   = 0x0800,   // resolve machine name in UNC targets pointing to local machine (used with SLDF_KEEP_LOCAL_IDLIST_FOR_UNC_TARGET)
    SLR_UPDATE_MACHINE_AND_SID    = 0x1000,   // update machine GUID and user SID if necessary
} SLR_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(SLR_FLAGS)")

// IShellLink::GetPath fFlags
typedef [v1_enum] enum SLGP_FLAGS
{
    SLGP_SHORTPATH          = 0x0001,
    SLGP_UNCPRIORITY        = 0x0002,
    SLGP_RAWPATH            = 0x0004,
    SLGP_RELATIVEPRIORITY   = 0x0008,
} SLGP_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(SLGP_FLAGS)")

[
    uuid(000214EE-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface IShellLinkA : IUnknown
{
    HRESULT GetPath(
        [out, string, size_is(cch)] LPSTR pszFile,
        [in] int cch,
        [in, out, unique] WIN32_FIND_DATAA *pfd,
        [in] DWORD fFlags);

    HRESULT GetIDList(
        [out] PIDLIST_ABSOLUTE * ppidl);

    HRESULT SetIDList(
        [in] PCIDLIST_ABSOLUTE pidl);

    HRESULT GetDescription(
        [out, string, size_is(cch)] LPSTR pszName,
        [in] int cch);

    HRESULT SetDescription(
        [in, string] LPCSTR pszName);

    HRESULT GetWorkingDirectory(
        [out, string, size_is(cch)] LPSTR pszDir,
        [in] int cch);

    HRESULT SetWorkingDirectory(
        [in, string] LPCSTR pszDir);

    HRESULT GetArguments(
        [out, string, size_is(cch)] LPSTR pszArgs,
        [in] int cch);

    HRESULT SetArguments(
        [in, string] LPCSTR pszArgs);

    HRESULT GetHotkey(
        [out] WORD *pwHotkey);

    HRESULT SetHotkey(
        [in] WORD wHotkey);

    HRESULT GetShowCmd(
        [out] int *piShowCmd);

    HRESULT SetShowCmd(
        [in] int iShowCmd);

    HRESULT GetIconLocation(
        [out, string, size_is(cch)] LPSTR pszIconPath,
        [in] int cch,
        [out] int *piIcon);

    HRESULT SetIconLocation(
        [in, string] LPCSTR pszIconPath,
        [in] int iIcon);

    HRESULT SetRelativePath(
        [in, string] LPCSTR pszPathRel,
        [in] DWORD dwReserved);

    HRESULT Resolve(
        [in, unique] HWND hwnd,
        [in] DWORD fFlags);

    HRESULT SetPath(
        [in, string] LPCSTR pszFile);
}

[
    uuid(000214F9-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface IShellLinkW : IUnknown
{
    HRESULT GetPath(
        [out, string, size_is(cch)] LPWSTR pszFile,
        [in] int cch,
        [in, out, unique] WIN32_FIND_DATAW *pfd,
        [in] DWORD fFlags);

    HRESULT GetIDList(
        [out] PIDLIST_ABSOLUTE * ppidl);

    HRESULT SetIDList(
        [in, unique] PCIDLIST_ABSOLUTE pidl);

    HRESULT GetDescription(
        [out, string, size_is(cch)] LPWSTR pszName,
        int cch);

    HRESULT SetDescription(
        [in, string] LPCWSTR pszName);

    HRESULT GetWorkingDirectory(
        [out, string, size_is(cch)] LPWSTR pszDir,
        int cch);

    HRESULT SetWorkingDirectory(
        [in, string] LPCWSTR pszDir);

    HRESULT GetArguments(
        [out, string, size_is(cch)] LPWSTR pszArgs,
        [in] int cch);

    HRESULT SetArguments(
        [in, string] LPCWSTR pszArgs);

    HRESULT GetHotkey(
        [out] WORD *pwHotkey);

    HRESULT SetHotkey(
        [in] WORD wHotkey);

    HRESULT GetShowCmd(
        [out] int *piShowCmd);

    HRESULT SetShowCmd(
        [in] int iShowCmd);

    HRESULT GetIconLocation(
        [out, string, size_is(cch)] LPWSTR pszIconPath,
        [in] int cch,
        [out] int *piIcon);

    HRESULT SetIconLocation(
        [in, string] LPCWSTR pszIconPath,
        [in] int iIcon);

    HRESULT SetRelativePath(
        [in, string] LPCWSTR pszPathRel,
        [in] DWORD dwReserved);

    HRESULT Resolve(
        [in, unique] HWND hwnd,
        [in] DWORD fFlags);

    HRESULT SetPath(
        [in, string] LPCWSTR pszFile);
}
[
    uuid(45e2b4ae-b1c3-11d0-b92f-00a0c90312e1),
    object,
    pointer_default(unique)
#ifdef BUILD_SPLIT_AS_IE
    ,local
#endif
]
interface IShellLinkDataList : IUnknown
{
    [local] HRESULT AddDataBlock(
        [in, annotation("__in")] void * pDataBlock);

    [local] HRESULT CopyDataBlock(
        [in, annotation("__in")] DWORD dwSig,
        [out, annotation("__deref_out")] void **ppDataBlock);

    HRESULT RemoveDataBlock(
        [in] DWORD dwSig);

    // flags are SLDF_ values as defined in shlobj.h
    HRESULT GetFlags(
        [out] DWORD *pdwFlags);

    HRESULT SetFlags(
        [in] DWORD dwFlags);
}


cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN2K)")

// Link resolution helpers - called when a link is created or needs to be resolved.

[
    object,
    uuid(5cd52983-9449-11d2-963a-00c04f79adf0),
    pointer_default(unique)
]
interface IResolveShellLink : IUnknown
{
    HRESULT ResolveShellLink(
        [in] IUnknown *punkLink,
        [in] HWND hwnd,
        [in] DWORD fFlags);
}

cpp_quote("#endif  // NTDDI_WIN2K")

// New for XP, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

[
    object,
    uuid(49ff1172-eadc-446d-9285-156453a6431c),
    pointer_default(unique)
]
interface IActionProgressDialog : IUnknown
{
    [v1_enum] enum _SPINITF 
    {
        SPINITF_NORMAL         = 0x00000000,      // default normal progress behavior
        SPINITF_MODAL          = 0x00000001,      // call punkSite->EnableModeless() or EnableWindow()
        SPINITF_NOMINIMIZE     = 0x00000008,      // Do not have a minimize button in the caption bar.
    };
    typedef DWORD SPINITF;

    HRESULT Initialize(
        [in] SPINITF flags,
        [in, unique, string] LPCWSTR pszTitle,
        [in, unique, string] LPCWSTR pszCancel);

    HRESULT Stop();
}

// HW Event Handler Interface
[
    object,
    uuid(C1FB73D0-EC3A-4ba2-B512-8CDB9187B6D1),
    pointer_default(unique)
]
interface IHWEventHandler : IUnknown
{
    HRESULT Initialize(
        [in, string] LPCWSTR pszParams);

    HRESULT HandleEvent(
        [in, string] LPCWSTR pszDeviceID,
        [in, string] LPCWSTR pszAltDeviceID,
        [in, string] LPCWSTR pszEventType);

    HRESULT HandleEventWithContent(
        [in, string] LPCWSTR pszDeviceID,
        [in, string] LPCWSTR pszAltDeviceID,
        [in, string] LPCWSTR pszEventType,
        [in, string] LPCWSTR pszContentTypeHandler,
        [in] IDataObject* pdataobject);
}

// HW Event Handler Interface 2
[
    object,
    uuid(CFCC809F-295D-42e8-9FFC-424B33C487E6),
    pointer_default(unique)
]
interface IHWEventHandler2 : IHWEventHandler
{
    HRESULT HandleEventWithHWND(
        [in, string] LPCWSTR pszDeviceID,
        [in, string] LPCWSTR pszAltDeviceID,
        [in, string] LPCWSTR pszEventType,
        [in] HWND hwndOwner);
}

// Do not use 0x1, it was used to indicate cancellation in legacy autoplay.
cpp_quote("#define ARCONTENT_AUTORUNINF             0x00000002   // That's the one we have today, and always had")
cpp_quote("#define ARCONTENT_AUDIOCD                0x00000004   // Audio CD (not MP3 and the like, the stuff you buy at the store)")
cpp_quote("#define ARCONTENT_DVDMOVIE               0x00000008   // DVD Movie (not MPEGs, the stuff you buy at the store)")
cpp_quote("#define ARCONTENT_BLANKCD                0x00000010   // Blank CD-R/CD-RW)")
cpp_quote("#define ARCONTENT_BLANKDVD               0x00000020   // Blank DVD-R/DVD-RW")
cpp_quote("#define ARCONTENT_UNKNOWNCONTENT         0x00000040   // Whatever files.  Mean that it's formatted.")
cpp_quote("#define ARCONTENT_AUTOPLAYPIX            0x00000080   // Any files classified by shell as image. (jpg, bmp, etc.)")
cpp_quote("#define ARCONTENT_AUTOPLAYMUSIC          0x00000100   // Any files classified by shell as music. (wma, mp3, etc.)")
cpp_quote("#define ARCONTENT_AUTOPLAYVIDEO          0x00000200   // Any files classified by shell as video. (mpg, avi, etc.)")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define ARCONTENT_VCD                    0x00000400   // VCD format")
cpp_quote("#define ARCONTENT_SVCD                   0x00000800   // Super-VCD format")
cpp_quote("#define ARCONTENT_DVDAUDIO               0x00001000   // DVD-Audio")
cpp_quote("#define ARCONTENT_BLANKBD                0x00002000   // Blank BD-R/BD-RW")
cpp_quote("#define ARCONTENT_BLURAY                 0x00004000   // Blu-ray Disc")
cpp_quote("#define ARCONTENT_NONE                   0x00000000   // Empty (but formatted)")
cpp_quote("#define ARCONTENT_MASK                   0x00007FFE   // Bits that denote valid content types")

cpp_quote("#define ARCONTENT_PHASE_UNKNOWN          0x00000000   // We can be in any phase.  This is XP behavior.")
cpp_quote("#define ARCONTENT_PHASE_PRESNIFF         0x10000000   // These are contents we know w/o scanning the media for complete data (e.g. Audio track, DVD Movie).")
cpp_quote("#define ARCONTENT_PHASE_SNIFFING         0x20000000   // We are in the middle of searching the media.  There could be more contents to be found than currently reported.")
cpp_quote("#define ARCONTENT_PHASE_FINAL            0x40000000   // We have finished searching; contents we report are final.")
cpp_quote("#define ARCONTENT_PHASE_MASK             0x70000000   // Bits that denote what phase we are in the Autoplay process.")
cpp_quote("#endif  // NTDDI_VISTA")

// HW Event Handler Interface
[
    object,
    uuid(DDEFE873-6997-4e68-BE26-39B633ADBE12),
    pointer_default(unique)
]
interface IQueryCancelAutoPlay : IUnknown
{
    HRESULT AllowAutoPlay(
        [in, string] LPCWSTR pszPath,
        [in] DWORD dwContentType,
        [in, string] LPCWSTR pszLabel,
        [in] DWORD dwSerialNumber);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

//
// IDynamicHWHandler is a new feature in AutoPlay V3 (Vista)
// A handler can register this interface for show/hide itself from the Autoplay prompt dialog.
// Additionally, it may specify a different action string than one supplied by the static
// handler registration under HKLM.
//
// params:
//  [in]  pszDeviceID - DevicePath or drive root (e.g. G:\),
//  [in]  dwContentType - bitfield of content types detected so far, similar to the param in IQueryCancelAutoPlay
//  [out] *ppszAction - if not NULL, use this as the Action string.
//                      if NULL, fallback to default static action string.
//
// returns:
//  S_OK = show, S_FALSE = hide, E_xx = error
//
// Dynamic HW Handler Interface
[
    object,
    uuid(DC2601D7-059E-42fc-A09D-2AFD21B6D5F7),
    pointer_default(unique)
]
interface IDynamicHWHandler : IUnknown
{
    HRESULT GetDynamicInfo(
        [in, string] LPCWSTR pszDeviceID,
        [in] DWORD dwContentType,
        [out, string] LPWSTR* ppszAction);
}

cpp_quote("#endif  // NTDDI_VISTA")

[
    object,
    uuid(49ff1173-eadc-446d-9285-156453a6431c),
    pointer_default(unique)
]
interface IActionProgress : IUnknown
{
    [v1_enum] enum _SPBEGINF 
    {
        SPBEGINF_NORMAL             = 0x00000000,      // default normal progress behavior
        SPBEGINF_AUTOTIME           = 0x00000002,      // automatically updates the "time remaining" text
        SPBEGINF_NOPROGRESSBAR      = 0x00000010,      // Don't display the progress bar (SetProgress() wont be called)
        SPBEGINF_MARQUEEPROGRESS    = 0x00000020,      // use marquee progress (comctl32 v6 required)
        SPBEGINF_NOCANCELBUTTON     = 0x00000040,      // no cancel button
    };
    typedef DWORD SPBEGINF;

    typedef [v1_enum] enum _SPACTION {
        SPACTION_NONE                   = 0,
        SPACTION_MOVING,
        SPACTION_COPYING,
        SPACTION_RECYCLING,
        SPACTION_APPLYINGATTRIBS,
        SPACTION_DOWNLOADING,
        SPACTION_SEARCHING_INTERNET,
        SPACTION_CALCULATING,
        SPACTION_UPLOADING,
        SPACTION_SEARCHING_FILES,
        SPACTION_DELETING,                            // Vista or higher
        SPACTION_RENAMING,                            // Vista or higher
        SPACTION_FORMATTING,                          // Vista or higher
        SPACTION_COPY_MOVING,                         // Move as copy-delete, Windows 7 or higher
    } SPACTION;

    typedef [v1_enum] enum _SPTEXT
    {
        SPTEXT_ACTIONDESCRIPTION        = 1,
        SPTEXT_ACTIONDETAIL,
    } SPTEXT;

    HRESULT Begin(
        [in] SPACTION action,
        [in] SPBEGINF flags);

    HRESULT UpdateProgress(
        [in] ULONGLONG ulCompleted,
        [in] ULONGLONG ulTotal);

    HRESULT UpdateText(
        [in] SPTEXT sptext,
        [in, string] LPCWSTR pszText,
        [in] BOOL fMayCompact);

    HRESULT QueryCancel([out] BOOL * pfCancelled);

    HRESULT ResetCancel();

    HRESULT End();

}

//cpp_quote("#endif  // NTDDI_WINXP")

//  The IShellExtInit interface is used by the explorer to initialize shell
// extension objects. The explorer (1) calls CoCreateInstance (or equivalent)
// with the registered CLSID and IID_IShellExtInit, (2) calls its Initialize
// member, then (3) calls its QueryInterface to a particular interface (such
// as IContextMenu or IPropSheetExt and (4) performs the rest of operation.
//
// IShellExtInit::Initialize
//
//  This member function is called when the explorer is initializing either
// context menu extension, property sheet extension or non-default drag-drop
// extension.
//
//  Parameters: (context menu or property sheet extension)
//   pidlFolder -- Specifies the parent folder
//   lpdobj -- Spefifies the set of items selected in that folder.
//   hkeyProgID -- Specifies the type of the focused item in the selection.
//
//  Parameters: (non-default drag-and-drop extension)
//   pidlFolder -- Specifies the target (destination) folder
//   lpdobj -- Specifies the items that are dropped (see the description
//    about shell's clipboard below for clipboard formats).
//   hkeyProgID -- Specifies the folder type.

// used to initialize an object on a remote computer (server)
[
    uuid(000214E8-0000-0000-C000-000000000046),
    object,
    local,
    pointer_default(unique)
]
interface IShellExtInit : IUnknown
{
    HRESULT Initialize(
        [in, unique, annotation("__in_opt")] PCIDLIST_ABSOLUTE pidlFolder,
        [in, unique, annotation("__in_opt")] IDataObject *pdtobj,
        [in, unique, annotation("__in_opt")] HKEY hkeyProgID);
}
typedef IShellExtInit * LPSHELLEXTINIT;


//  The explorer uses the IShellPropSheetExt to allow property sheet
// extensions or control panel extensions to add additional property
// sheet pages.
//
// IShellPropSheetExt::AddPages
//
//  The explorer calls this member function when it finds a registered
// property sheet extension for a particular type of object. For each
// additional page, the extension creates a page object by calling
// CreatePropertySheetPage API and calls lpfnAddPage.
//
//  Parameters:
//   lpfnAddPage -- Specifies the callback function.
//   lParam -- Specifies the opaque handle to be passed to the callback function.
//
//
// IShellPropSheetExt::ReplacePage
//
//  The explorer never calls this member of property sheet extensions. The
// explorer calls this member of control panel extensions, so that they
// can replace some of default control panel pages (such as a page of
// mouse control panel).
//
//  Parameters:
//   uPageID -- Specifies the page to be replaced.
//   lpfnReplace Specifies the callback function.
//   lParam -- Specifies the opaque handle to be passed to the callback function.
//
[
    uuid(000214E9-0000-0000-C000-000000000046),
    object,
    local,
    pointer_default(unique)
]
interface IShellPropSheetExt : IUnknown
{
    [v1_enum] enum _EXPPS
    {
        EXPPS_FILETYPES     = 0x00000001,
    };
    typedef UINT EXPPS;

    HRESULT AddPages(
        [in, annotation("__in")] LPFNSVADDPROPSHEETPAGE pfnAddPage,
        [in, annotation("__in")] LPARAM lParam);

    HRESULT ReplacePage(
        [in, annotation("__in")] EXPPS uPageID,
        [in, annotation("__in")] LPFNSVADDPROPSHEETPAGE pfnReplaceWith,
        [in, annotation("__in")] LPARAM lParam);
}
typedef IShellPropSheetExt * LPSHELLPROPSHEETEXT;

[
    uuid(000214FE-0000-0000-C000-000000000046),
    object,
    pointer_default(unique)
]
interface IRemoteComputer : IUnknown
{
    // function is called when the explorer is initializing or
    // enumerating the name space extension. If failure is returned during
    // enumeration, the extension won't appear for this computer. Otherwise,
    // the extension will appear, and should target the given machine.
    //
    // pszMachine       Specifies the name of the machine to target. (\\server)
    // bEnumerationg    test to see if this object should be enumerated
    //                  on this server
    HRESULT Initialize(
        [in, string] LPCWSTR pszMachine,
        [in] BOOL bEnumerating);
}

[
    uuid(7307055c-b24a-486b-9f25-163e597a28a9),
    object,
    pointer_default(unique)
]
interface IQueryContinue : IUnknown
{
    HRESULT QueryContinue();    // S_OK -> Continue, S_FALSE -> Cancel
}

// This interface supplies a caller with an event that will be signaled
// by the callee to denote cancellation of a task.

[
    uuid(F279B885-0AE9-4b85-AC06-DDECF9408941),
    object,
    local,
    pointer_default(unique)
]
interface IObjectWithCancelEvent : IUnknown
{
    // Call this function to retrieve an event that will be signaled when
    // the callee cancels the operation it's performing.
    // The caller is responsible for closing the returned handle.
    HRESULT GetCancelEvent([out, annotation("__out")] HANDLE *phEvent);
}

[
    uuid(ba9711ba-5893-4787-a7e1-41277151550b),
    object,
    pointer_default(unique)
]
interface IUserNotification : IUnknown
{
    HRESULT SetBalloonInfo(
        [in, unique, string] LPCWSTR pszTitle,
        [in, unique, string] LPCWSTR pszText,
        [in] DWORD dwInfoFlags);

    HRESULT SetBalloonRetry(
        [in] DWORD dwShowTime,  // times in msec
        [in] DWORD dwInterval,
        [in] UINT cRetryCount);

    HRESULT SetIconInfo(
        [in, unique] HICON hIcon,
        [in, unique, string] LPCWSTR pszToolTip);

    HRESULT Show(
        [in, unique] IQueryContinue *pqc,
        [in] DWORD dwContinuePollInterval);

    HRESULT PlaySound([in, string] LPCWSTR pszSoundName);
}

[
    uuid(19108294-0441-4AFF-8013-FA0A730B0BEA),
    object
]
interface IUserNotificationCallback : IUnknown
{
    // All of these return S_OK to continue, S_FALSE or other error codes to stop
    // These are all "fire and forget" callbacks. Dont pump messages during these
    // callbacks...
    HRESULT OnBalloonUserClick([in] POINT * pt);
    HRESULT OnLeftClick([in] POINT * pt);
    HRESULT OnContextMenu([in] POINT * pt);
}

[
    uuid(215913CC-57EB-4FAB-AB5A-E5FA7BEA2A6C),
    object,
    pointer_default(unique)
]
interface IUserNotification2 : IUnknown
{
    HRESULT SetBalloonInfo(
        [in, unique, string] LPCWSTR pszTitle,
        [in, unique, string] LPCWSTR pszText,
        [in] DWORD dwInfoFlags);

    HRESULT SetBalloonRetry(
        [in] DWORD dwShowTime,  // times in msec
        [in] DWORD dwInterval,
        [in] UINT cRetryCount);

    HRESULT SetIconInfo(
        [in, unique] HICON hIcon,
        [in, unique, string] LPCWSTR pszToolTip);

    HRESULT Show(
        [in, unique] IQueryContinue *pqc,
        [in] DWORD dwContinuePollInterval,
        [in, unique] IUserNotificationCallback *pSink);

    HRESULT PlaySound([in, string] LPCWSTR pszSoundName);
}

// interface for describing the limits placed on a name, used for validation
// parsing and translation.

[
    uuid(1df0d7f1-b267-4d28-8b10-12e23202a5c4)
]
interface IItemNameLimits : IUnknown
{
    HRESULT GetValidCharacters(
        [out, string] LPWSTR *ppwszValidChars,
        [out, string] LPWSTR *ppwszInvalidChars);

    HRESULT GetMaxLength(
        [in, string] LPCWSTR pszName,
        [out] int *piMaxNameLen);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

[
    object,
    uuid(a0ffbc28-5482-4366-be27-3e81e78e06c2),
    pointer_default(unique)
]
interface ISearchFolderItemFactory : IUnknown
{
    HRESULT SetDisplayName(
        [in, string] LPCWSTR pszDisplayName);

    HRESULT SetFolderTypeID(
        [in] FOLDERTYPEID ftid);

    HRESULT SetFolderLogicalViewMode(
        [in] FOLDERLOGICALVIEWMODE flvm);

    HRESULT SetIconSize(
        [in] int iIconSize);

    HRESULT SetVisibleColumns(
        [in] UINT cVisibleColumns,
        [in, size_is(cVisibleColumns)] PROPERTYKEY *rgKey);

    HRESULT SetSortColumns(
        [in] UINT cSortColumns,
        [in, size_is(cSortColumns)] SORTCOLUMN *rgSortColumns);

    HRESULT SetGroupColumn(
        [in] REFPROPERTYKEY keyGroup);

    HRESULT SetStacks(
        [in] UINT cStackKeys,
        [in, size_is(cStackKeys)] PROPERTYKEY *rgStackKeys);

    HRESULT SetScope(
        [in] IShellItemArray *psiaScope);

    HRESULT SetCondition(
        [in] ICondition *pCondition);

    HRESULT GetShellItem(
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);    // returns IShellItem, navigate to this

    HRESULT GetIDList(
        [out] PIDLIST_ABSOLUTE *ppidl);
}

cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#if (_WIN32_IE >= 0x0400)")

// --- IExtractImage
// this interface is provided for objects to provide a thumbnail image.
// IExtractImage::GetLocation()
//      Gets a path description of the image that is to be extracted. This is used to
//      identify the image in the view so that multiple instances of the same image can reuse the
//      original image. If *pdwFlags == IEIFLAG_ASYNC and the result is E_PENDING, then *pdwPriority
//      is used to return the priority of the item, this is usually a measure of how long it will take
//      to perform the extraction. *pdwFlags can return IEIFLAG_CACHE if the view should cache a copy
//      of the image for future reference and faster access. This flag is used to tell the difference
//      between file formats that cache a thumbnail image such as Flashpix or Office documents, and those
//      that don't cache one.
// IExtractImage::Extract()
//      Extract the thumbnail of the specified size. If GetLocation() returned the values indicating
//      it is free-threaded and can be placed on a background thread. If the object
//      supports IRunnableTask as well, then long extractions can be started and paused as appropriate.
//      At this point it is asssumed the object is free-threaded.
//      If dwRecClrDepth contains a recommended Colour depth
//      If *phBmpthumbnail is non NULL, then it contains the destination bitmap that should be used.

cpp_quote("#define IEI_PRIORITY_MAX        ITSAT_MAX_PRIORITY")
cpp_quote("#define IEI_PRIORITY_MIN        ITSAT_MIN_PRIORITY")
cpp_quote("#define IEIT_PRIORITY_NORMAL     ITSAT_DEFAULT_PRIORITY")

cpp_quote("#define IEIFLAG_ASYNC       0x0001      // (deprecated) ask the extractor if it supports ASYNC extract (free threaded)")
cpp_quote("#define IEIFLAG_CACHE       0x0002      // returned from the extractor if it does NOT cache the thumbnail")
cpp_quote("#define IEIFLAG_ASPECT      0x0004      // passed to the extractor to beg it to render to the aspect ratio of the supplied rect")
cpp_quote("#define IEIFLAG_OFFLINE     0x0008      // if the extractor shouldn't hit the net to get any content neede for the rendering")
cpp_quote("#define IEIFLAG_GLEAM       0x0010      // does the image have a gleam ? this will be returned if it does")
cpp_quote("#define IEIFLAG_SCREEN      0x0020      // render as if for the screen  (this is exlusive with IEIFLAG_ASPECT )")
cpp_quote("#define IEIFLAG_ORIGSIZE    0x0040      // render to the approx size passed, but crop if neccessary")
cpp_quote("#define IEIFLAG_NOSTAMP     0x0080      // returned from the extractor if it does NOT want an icon stamp on the thumbnail")
cpp_quote("#define IEIFLAG_NOBORDER    0x0100      // returned from the extractor if it does NOT want an a border around the thumbnail")
cpp_quote("#define IEIFLAG_QUALITY     0x0200      // passed to the Extract method to indicate that a slower, higher quality image is desired, re-compute the thumbnail")
cpp_quote("#define IEIFLAG_REFRESH     0x0400      // returned from the extractor if it would like to have Refresh Thumbnail available")

[
    uuid(BB2E617C-0920-11d1-9A0B-00C04FC2D6C1),
    object,
    pointer_default(unique)
]
interface IExtractImage : IUnknown
{
    HRESULT GetLocation(
        [out, string, size_is(cch)] LPWSTR pszPathBuffer,
        [in] DWORD cch,
        [in, out, unique] DWORD *pdwPriority,
        [in] const SIZE * prgSize,
        [in] DWORD dwRecClrDepth,
        [in, out] DWORD *pdwFlags);

   HRESULT Extract(
       [out] HBITMAP *phBmpThumbnail);
}
typedef IExtractImage * LPEXTRACTIMAGE;

cpp_quote("#endif")

cpp_quote("#if (_WIN32_IE >= 0x0500)")

// GetDateStamp : returns the date stamp associated with the image. If this image is already cached,
//                then it is easy to find out if the image is out of date.

[
    uuid(953BB1EE-93B4-11d1-98A3-00C04FB687DA),
    object,
    pointer_default(unique)
]
interface IExtractImage2 : IExtractImage
{
    HRESULT GetDateStamp([out] FILETIME *pDateStamp);
}
typedef IExtractImage2 * LPEXTRACTIMAGE2;

[
    uuid(e35b4b2e-00da-4bc1-9f13-38bc11f5d417),
    object,
    pointer_default(unique)
]
interface IThumbnailHandlerFactory : IUnknown
{
    HRESULT GetThumbnailHandler(
        [in] PCUITEMID_CHILD pidlChild,
        [in, unique] IBindCtx *pbc,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);
}

[
    uuid(b3a4b685-b685-4805-99d9-5dead2873236),  // IID_IParentAndItem
    object,
    pointer_default(unique)
]
interface IParentAndItem : IUnknown
{
    // 2 ways to init
    //      pidlParent == NULL
    //      psf is folder, pidlChild is child relative to psf
    HRESULT SetParentAndItem(
        [in, unique] PCIDLIST_ABSOLUTE pidlParent,
        [in, unique] IShellFolder *psf,
        [in] PCUITEMID_CHILD pidlChild);

    // all params optional
    //      ppidlParent gets full pidl to parent of item
    //      ppsf gets parent folder for item
    //      ppidlChild gets item relitve to psf
    [local]
    HRESULT GetParentAndItem(
        [out, annotation("__deref_opt_out")] PIDLIST_ABSOLUTE *ppidlParent,
        [out, annotation("__deref_opt_out")] IShellFolder **ppsf,
        [out, annotation("__deref_opt_out")] PITEMID_CHILD *ppidlChild);

    [call_as(GetParentAndItem)]
    HRESULT RemoteGetParentAndItem(
        [out] PIDLIST_ABSOLUTE *ppidlParent,
        [out] IShellFolder **ppsf,
        [out] PITEMID_CHILD *ppidlChild);
}

cpp_quote("#endif")



//-------------------------------------------------------------------------
//
// IDockingWindow interface
//
//   An object (docking window) implements this interface so the site can
// communicate with it.  An example of a docking window is a toolbar.
//
// [Member functions]
//
// IDockingWindow::ShowDW(fShow)
//   Shows or hides the docking window.
//
// IDockingWindow::CloseDW(dwReserved)
//   Closes the docking window.  dwReserved must be 0.
//
// IDockingWindow::ResizeBorderDW(prcBorder, punkToolbarSite, fReserved)
//   Resizes the docking window's border to *prcBorder.  fReserved must
//   be 0.
//
// IObjectWithSite::SetSite(punkSite)
//   IDockingWindow usually paired with IObjectWithSite.
//   Provides the IUnknown pointer of the site to the docking window.
//
//-------------------------------------------------------------------------

[
    uuid(012dd920-7b26-11d0-8ca9-00a0c92dbfe8),
    object
]
interface IDockingWindow : IOleWindow
{
    HRESULT ShowDW([in] BOOL fShow);

    HRESULT CloseDW([in] DWORD dwReserved);

    HRESULT ResizeBorderDW(
        [in, unique] LPCRECT prcBorder,
        [in, unique] IUnknown* punkToolbarSite,
        [in] BOOL fReserved);
}

//-------------------------------------------------------------------------
//
// IDeskBand interface
//
//
// [Member functions]
//
// IDeskBand::GetBandInfo(dwBandID, dwViewMode, pdbi)
//   Returns info on the given band in *pdbi, according to the mask
//   field in the DESKBANDINFO structure and the given viewmode.
//
//-------------------------------------------------------------------------


// Mask values for DESKBANDINFO
cpp_quote("#define DBIM_MINSIZE    0x0001")
cpp_quote("#define DBIM_MAXSIZE    0x0002")
cpp_quote("#define DBIM_INTEGRAL   0x0004")
cpp_quote("#define DBIM_ACTUAL     0x0008")
cpp_quote("#define DBIM_TITLE      0x0010")
cpp_quote("#define DBIM_MODEFLAGS  0x0020")
cpp_quote("#define DBIM_BKCOLOR    0x0040")

cpp_quote("#include <pshpack8.h>")

typedef struct DESKBANDINFO
{
    DWORD       dwMask;
    POINTL      ptMinSize;
    POINTL      ptMaxSize;
    POINTL      ptIntegral;
    POINTL      ptActual;
    WCHAR       wszTitle[256];
    DWORD       dwModeFlags;
    COLORREF    crBkgnd;
} DESKBANDINFO;

cpp_quote("#include <poppack.h>")   // Return to byte packing

// DESKBANDINFO dwModeFlags values
cpp_quote("#define DBIMF_NORMAL            0x0000")
cpp_quote("#define DBIMF_FIXED             0x0001")
cpp_quote("#define DBIMF_FIXEDBMP          0x0004   // a fixed background bitmap (if supported)")
cpp_quote("#define DBIMF_VARIABLEHEIGHT    0x0008")
cpp_quote("#define DBIMF_UNDELETEABLE      0x0010")
cpp_quote("#define DBIMF_DEBOSSED          0x0020")
cpp_quote("#define DBIMF_BKCOLOR           0x0040")
cpp_quote("#define DBIMF_USECHEVRON        0x0080")
cpp_quote("#define DBIMF_BREAK             0x0100")
cpp_quote("#define DBIMF_ADDTOFRONT        0x0200")
cpp_quote("#define DBIMF_TOPALIGN          0x0400")
cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("#define DBIMF_NOGRIPPER         0x0800")
cpp_quote("#define DBIMF_ALWAYSGRIPPER     0x1000")
cpp_quote("#define DBIMF_NOMARGINS         0x2000")
cpp_quote("#endif  // NTDDI_VISTA")

// GetBandInfo view mode values
cpp_quote("#define DBIF_VIEWMODE_NORMAL         0x0000")
cpp_quote("#define DBIF_VIEWMODE_VERTICAL       0x0001")
cpp_quote("#define DBIF_VIEWMODE_FLOATING       0x0002")
cpp_quote("#define DBIF_VIEWMODE_TRANSPARENT    0x0004")

// Command Target IDs
enum tagDESKBANDCID 
{
    DBID_BANDINFOCHANGED    = 0,
    DBID_SHOWONLY           = 1,
    DBID_MAXIMIZEBAND       = 2,      // Maximize the specified band (VT_UI4 == dwID)
    DBID_PUSHCHEVRON        = 3,
    DBID_DELAYINIT          = 4,      // Note: _bandsite_ calls _band_ with this code
    DBID_FINISHINIT         = 5,      // Note: _bandsite_ calls _band_ with this code
    DBID_SETWINDOWTHEME     = 6,      // Note: _bandsite_ calls _band_ with this code
    DBID_PERMITAUTOHIDE     = 7,
};

cpp_quote("#define DBPC_SELECTFIRST    (DWORD)-1")
cpp_quote("#define DBPC_SELECTLAST     (DWORD)-2")

cpp_quote("#define CGID_DeskBand IID_IDeskBand")

[
    uuid(EB0FE172-1A3A-11D0-89B3-00A0C90A90AC),
    object,
]
interface IDeskBand : IDockingWindow
{
    HRESULT GetBandInfo(
        [in] DWORD dwBandID,
        [in] DWORD dwViewMode,
        [in, out] DESKBANDINFO* pdbi);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
//-------------------------------------------------------------------------
//
// IDeskBandInfo interface
//
//
// [Member functions]
//
// IDeskBandInfo::GetDefaultBandWidth(dwBandID, dwViewMode, puWidth)
//   Call back by bandsite to get the band width that bandsite uses to set
//   the default width of the band when the band is first added/docked to
//   bandsite.
//
//-------------------------------------------------------------------------
[
    uuid(77E425FC-CBF9-4307-BA6A-BB5727745661),
    object,
]
interface IDeskBandInfo : IUnknown
{
    HRESULT GetDefaultBandWidth(
        [in] DWORD dwBandID,
        [in] DWORD dwViewMode,
        [out] int *pnWidth);
}

//-------------------------------------------------------------------------
//
// IDeskBand2 interface
//
//
// [Member functions]
//
// IDeskBand2::CanRenderComposited(pfCanRenderComposited)
//   Does the deskband support composited rendering (glass/translucent)?
//
// IDeskBand2::SetCompositionState(fCompositionEnabled)
//   Tell the deskband to render with or without composition.
//
// IDeskBand2::GetCompositionState(pfCompositionEnabled)
//   Does the deskband currently render with or without composition?
//
//-------------------------------------------------------------------------
[
    uuid(79D16DE4-ABEE-4021-8D9D-9169B261D657),
    object,
]
interface IDeskBand2 : IDeskBand
{
    HRESULT CanRenderComposited([out] BOOL *pfCanRenderComposited);

    HRESULT SetCompositionState([in] BOOL fCompositionEnabled);

    HRESULT GetCompositionState([out] BOOL *pfCompositionEnabled);
}

cpp_quote("#endif  // NTDDI_VISTA")

//-------------------------------------------------------------------------
//
// ITaskbarList interface
//
//
// [Member functions]
//
// ITaskbarList::HrInit()
//   This function must be called first to validate use of other members.
//
// ITaskbarList::AddTab(hwnd)
//   This function adds a tab for hwnd to the taskbar.
//
// ITaskbarList::DeleteTab(hwnd)
//   This function deletes a tab for hwnd from the taskbar.
//
// ITaskbarList::ActivateTab(hwnd)
//   This function activates the tab associated with hwnd on the taskbar.
//
// ITaskbarList::SetActivateAlt(hwnd)
//   This function marks hwnd in the taskbar as the active tab
//
//-------------------------------------------------------------------------
[
    uuid(56FDF342-FD6D-11d0-958A-006097C9A090),
    object,
]
interface ITaskbarList : IUnknown
{
    HRESULT HrInit();

    HRESULT AddTab([in] HWND hwnd);

    HRESULT DeleteTab([in] HWND hwnd);

    HRESULT ActivateTab([in] HWND hwnd);

    HRESULT SetActiveAlt([in] HWND hwnd);
}

[
    uuid(602D4995-B13A-429b-A66E-1935E44F4317),
    object,
]
interface ITaskbarList2 : ITaskbarList
{
    HRESULT MarkFullscreenWindow(
        [in] HWND hwnd,
        [in] BOOL fFullscreen);
}

cpp_quote("#ifdef MIDL_PASS")
typedef IUnknown* HIMAGELIST;
cpp_quote("#endif")

typedef [v1_enum] enum THUMBBUTTONFLAGS
{
    THBF_ENABLED        =   0x00000000,
    THBF_DISABLED       =   0x00000001,
    THBF_DISMISSONCLICK =   0x00000002,
    THBF_NOBACKGROUND   =   0x00000004,
    THBF_HIDDEN         =   0x00000008,
    THBF_NONINTERACTIVE =   0x00000010,
} THUMBBUTTONFLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(THUMBBUTTONFLAGS)")

typedef [v1_enum] enum THUMBBUTTONMASK
{
    THB_BITMAP          =   0x00000001,
    THB_ICON            =   0x00000002,
    THB_TOOLTIP         =   0x00000004,
    THB_FLAGS           =   0x00000008,
} THUMBBUTTONMASK;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(THUMBBUTTONMASK)")

cpp_quote("#include <pshpack8.h>")

typedef struct THUMBBUTTON
{
    THUMBBUTTONMASK  dwMask;
    UINT    iId;
    UINT    iBitmap;
    HICON   hIcon;
    WCHAR   szTip[260];
    THUMBBUTTONFLAGS  dwFlags;
} THUMBBUTTON, *LPTHUMBBUTTON;

cpp_quote("#include <poppack.h>")

cpp_quote("#define THBN_CLICKED        0x1800")

[
    uuid(ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf),
    object,
]
interface ITaskbarList3 : ITaskbarList2
{
    // Flags for Setting Taskbar Progress state
    typedef [v1_enum] enum TBPFLAG
    {
        TBPF_NOPROGRESS     = 0x00000000,
        TBPF_INDETERMINATE  = 0x00000001,
        TBPF_NORMAL         = 0x00000002,
        TBPF_ERROR          = 0x00000004,
        TBPF_PAUSED         = 0x00000008,
    } TBPFLAG;
    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBPFLAG)")

    HRESULT SetProgressValue(
        [in] HWND hwnd,
        [in] ULONGLONG ullCompleted,
        [in] ULONGLONG ullTotal);

    HRESULT SetProgressState(
        [in] HWND hwnd,
        [in] TBPFLAG tbpFlags);

    HRESULT RegisterTab(
        [in] HWND hwndTab,
        [in] HWND hwndMDI);

    HRESULT UnregisterTab(
        [in] HWND hwndTab);

    HRESULT SetTabOrder(
        [in] HWND hwndTab,
        [in] HWND hwndInsertBefore);

    HRESULT SetTabActive(
        [in] HWND hwndTab,
        [in] HWND hwndMDI,
        [in] DWORD dwReserved);

    HRESULT ThumbBarAddButtons(
        [in] HWND hwnd,
        [in] UINT cButtons,
        [in, size_is(cButtons)] LPTHUMBBUTTON pButton);

    HRESULT ThumbBarUpdateButtons(
        [in] HWND hwnd,
        [in] UINT cButtons,
        [in, size_is(cButtons)] LPTHUMBBUTTON pButton);

    HRESULT ThumbBarSetImageList(
        [in] HWND hwnd,
        [in] HIMAGELIST himl);

    HRESULT SetOverlayIcon(
        [in] HWND hwnd, 
        [in] HICON hIcon,
        [in, unique, string] LPCWSTR pszDescription);

    HRESULT SetThumbnailTooltip(
        [in] HWND hwnd, 
        [in, unique, string] LPCWSTR pszTip);

    HRESULT SetThumbnailClip(
        [in] HWND hwnd, 
        [in] RECT *prcClip);
}

[
    uuid(c43dc798-95d1-4bea-9030-bb99e2983a1a),
    object,
]
interface ITaskbarList4 : ITaskbarList3
{
    // Flags for Setting Tab Properties 
    typedef [v1_enum] enum STPFLAG
    {
        STPF_NONE                       = 0x00000000,
        STPF_USEAPPTHUMBNAILALWAYS      = 0x00000001,
        STPF_USEAPPTHUMBNAILWHENACTIVE  = 0x00000002,
        STPF_USEAPPPEEKALWAYS           = 0x00000004,
        STPF_USEAPPPEEKWHENACTIVE       = 0x00000008,
    } STPFLAG;
    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(STPFLAG)")

    HRESULT SetTabProperties(
        [in] HWND hwndTab,
        [in] STPFLAG stpFlags);
}

[
    uuid(4CD19ADA-25A5-4A32-B3B7-347BEE5BE36B),
    object,
]
interface IStartMenuPinnedList : IUnknown
{
    //  if pitem is not pinned, return S_OK
    //  if pitem is pinned, the pitem is successfully removed from pinned list, return S_OK
    //  if pitem is pinned, the pitem fail to be removed from pinned list, return error HRESULT
    HRESULT RemoveFromList([in] IShellItem *pitem);
}

[
    object,
    uuid(3d73a659-e5d0-4d42-afc0-5121ba425c8d),     // IID_ICDBurn
    pointer_default(unique)
]
interface ICDBurn : IUnknown
{
    HRESULT GetRecorderDriveLetter(
        [out, string, size_is(cch)] LPWSTR pszDrive,
        [in] UINT cch);

    HRESULT Burn([in] HWND hwnd);

    HRESULT HasRecordableDrive([out] BOOL *pfHasRecorder);
}

// Wizard Extension objects.  These interfaces defined methods for extending
// Win32 wizard in a progromatic way.

// Range of ID's that extensions can used, these mustn't clash with
// the existing wizards dialog IDS.  (That enables them to still
// do PropSheet_SetCurSelByID).

cpp_quote("#define IDD_WIZEXTN_FIRST    0x5000")
cpp_quote("#define IDD_WIZEXTN_LAST     0x5100")


// This site object is requested via a QueryService of the objects site,
// it allows the extension to navigate in/out out itself, eg. when the
// extension has shown all of its pages and wants to navigate to the
// next page it would call GetNextPage and select the specified HPAGE.

// Wizard Extension Site
[
    uuid(88960f5b-422f-4e7b-8013-73415381c3c3),
    local
]
interface IWizardSite : IUnknown
{
    HRESULT GetPreviousPage([out, annotation("__out")] HPROPSHEETPAGE *phpage);

    HRESULT GetNextPage([out, annotation("__out")] HPROPSHEETPAGE *phpage);

    HRESULT GetCancelledPage([out, annotation("__out")] HPROPSHEETPAGE *phpage);
}

cpp_quote("#define SID_WizardSite IID_IWizardSite")


// A wizard extension is implemented using this object, the extension will declare the
// pages that it supports using the AddPages method, and then when its host needs to navigate
// into the extenion it will do so via GetFirstPage and selecting that.

// Wizard Extension
[
    uuid(c02ea696-86cc-491e-9b23-74394a0444a8),
    local
]
interface IWizardExtension : IUnknown
{
    HRESULT AddPages(
        [out, size_is(cPages), annotation("__out_ecount_part(cPages, *pnPagesAdded)")] HPROPSHEETPAGE* aPages,
        [in, annotation("__in")] UINT cPages,
        [out, annotation("__out __deref_out_range(0, cPages)")] UINT *pnPagesAdded);

    HRESULT GetFirstPage([out, annotation("__out")] HPROPSHEETPAGE *phpage);

    HRESULT GetLastPage([out, annotation("__out")] HPROPSHEETPAGE *phpage);
}


// The Web Wizard is a HTML host for wizard pages, it allows you
// create a HTML wizard starting at the URL defined via SetInitialURL.

// Web Wizard Page Extension
[
    uuid(0e6b3f66-98d1-48c0-a222-fbde74e2fbc5),
    local,
    pointer_default(unique)
]
interface IWebWizardExtension : IWizardExtension
{
    HRESULT SetInitialURL([in, string, annotation("__in")] LPCWSTR pszURL);

    HRESULT SetErrorURL([in, string, annotation("__in")] LPCWSTR pszErrorURL);
}

cpp_quote("#define SID_WebWizardHost IID_IWebWizardExtension")


// flags for the host to control the publishing wizard

cpp_quote ("#define SHPWHF_NORECOMPRESS             0x00000001  // don't allow/prompt for recompress of streams")
cpp_quote ("#define SHPWHF_NONETPLACECREATE         0x00000002  // don't create a network place when transfer is complete")
cpp_quote ("#define SHPWHF_NOFILESELECTOR           0x00000004  // don't show the file selector")
cpp_quote ("#define SHPWHF_USEMRU                   0x00000008  // For OPW.  Use the Most-Recently-Used Print Provider")
cpp_quote ("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote ("#define SHPWHF_ANYLOCATION              0x00000100  // allow publishing to any location")
cpp_quote ("#endif  // NTDDI_VISTA")
cpp_quote ("#define SHPWHF_VALIDATEVIAWEBFOLDERS    0x00010000  // enable web folders to validate network places (ANP support)")

// Web Publishing Wizard
[
    uuid(aa9198bb-ccec-472d-beed-19a4f6733f7a),
    local,
    pointer_default(unique)
]
interface IPublishingWizard : IWizardExtension
{
    HRESULT Initialize(
        [in, unique, annotation("__in_opt")] IDataObject *pdo,
        [in, annotation("__in")] DWORD dwOptions,
        [in, string, annotation("__in")] LPCWSTR pszServiceScope);

    HRESULT GetTransferManifest(
        [out, annotation("__out_opt")] HRESULT *phrFromTransfer,
        [out, annotation("__deref_opt_out")] IXMLDOMDocument **pdocManifest);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP) || (_WIN32_IE >= _WIN32_IE_IE70)")

// Object to host an IFolderView in a window.  This is used to build check mark selection
// UI for files.
// Shell Folder Host
[
    uuid(1ea58f02-d55a-411d-b09e-9e65ac21605b),
    local,
]
interface IFolderViewHost : IUnknown
{
    HRESULT Initialize(
        [in, annotation("__in")] HWND hwndParent,
        [in, annotation("__in")] IDataObject *pdo,
        [in, annotation("__in")] RECT *prc);
};

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

//  Event sink interface for IExplorerBrowser events
[
    uuid(361bbdc7-e6ee-4e13-be58-58e2240c810f),    // IID_IExplorerBrowserEvents
    object
]
interface IExplorerBrowserEvents : IUnknown
{
    // Returning failure from this will cancel the navigation.
    HRESULT OnNavigationPending([in] PCIDLIST_ABSOLUTE pidlFolder);

    // Called once the view window has been created.  Do any last minute modifcations
    //  to the view here before it is shown (set view modes, folder flags, etc...)
    HRESULT OnViewCreated([in] IShellView *psv);

    // Called once the navigation has succeeded (after OnViewCreated).
    HRESULT OnNavigationComplete([in] PCIDLIST_ABSOLUTE pidlFolder);

    // Called if a navigation failed, despite the call to IShellBrowser::BrowseObject succeeding.
    HRESULT OnNavigationFailed([in] PCIDLIST_ABSOLUTE pidlFolder);
}

// IExplorerBrowser::SetOptions() flags
typedef [v1_enum] enum EXPLORER_BROWSER_OPTIONS
{
    EBO_NONE               = 0x00000000,     // No options
    EBO_NAVIGATEONCE       = 0x00000001,     // Don't navigate after initial navigation
    EBO_SHOWFRAMES         = 0X00000002,     // Show with frame module manager on - otherwise, single view object
    EBO_ALWAYSNAVIGATE     = 0x00000004,     // Always navigate, even if you are attempting to navigate to the current folder
    EBO_NOTRAVELLOG        = 0x00000008,     // do not update travel log
    EBO_NOWRAPPERWINDOW    = 0x00000010,     // For legacy clients that need the browser parented directly on themselves
    EBO_HTMLSHAREPOINTVIEW = 0x00000020,     // Show WebView for sharepoint sites
} EXPLORER_BROWSER_OPTIONS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(EXPLORER_BROWSER_OPTIONS)")

// IExplorerBrowser::FillFromObject() flags
// Cannot conflict with SBSP_... flags from IShellBrowser::BrowseObject()
typedef [v1_enum] enum EXPLORER_BROWSER_FILL_FLAGS
{
    EBF_NONE                  = 0x0000000,   // No flags
    // Causes FillFromObject to populate the ResultsFolder with the
    // contents of the parent folders of the items in the DataObject
    // and then check-selects only the items that are in the DataObject
    EBF_SELECTFROMDATAOBJECT  = 0x0000100,   
    // don't regsiter a drop target for the view, this enables apps to register their own drop target
    // that they can use to receive the drops
    EBF_NODROPTARGET          = 0x0000200,   
} EXPLORER_BROWSER_FILL_FLAGS;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(EXPLORER_BROWSER_FILL_FLAGS)")

//
//  This allows you to host a simple browser (CLSID_ExplorerBrowser) that can be navigated
//  or host a view of a data object.   Use either BrowseToIDList or BrowseToObject to navigate
//  the browser or use FillWithDataObject to create the view on the data object.
//
[
    uuid(dfd3b6b5-c10c-4be9-85f6-a66969f402f6),
    object,
]
interface IExplorerBrowser : IUnknown
{
    // to clean up this object you must call ::Destroy.
    [local] HRESULT Initialize(
        [in, annotation("__in")] HWND hwndParent,
        [in, annotation("__in")] const RECT *prc,
        [in, unique, annotation("__in_opt")] const FOLDERSETTINGS *pfs);

    HRESULT Destroy();

    [local] HRESULT SetRect(
        [in, out, unique, annotation("__inout_opt")] HDWP *phdwp,
        [in, annotation("__in")] RECT rcBrowser);  // relative to hwndParent

    HRESULT SetPropertyBag([in, string] LPCWSTR pszPropertyBag);  // Property bag for view state persistence

    HRESULT SetEmptyText([in, string] LPCWSTR pszEmptyText);  // Displayed when view is empty

    HRESULT SetFolderSettings([in] const FOLDERSETTINGS *pfs);  // Sets how view displays / operates

    HRESULT Advise([in] IExplorerBrowserEvents *psbe, [out] DWORD *pdwCookie);

    HRESULT Unadvise([in] DWORD dwCookie);

    HRESULT SetOptions([in] EXPLORER_BROWSER_OPTIONS dwFlag);

    HRESULT GetOptions([out] EXPLORER_BROWSER_OPTIONS *pdwFlag);

    // navigate the browser to a particular location
    // uFlags contains SBSP_ flag values
    HRESULT BrowseToIDList([in] PCUIDLIST_RELATIVE pidl, [in] UINT uFlags);

    // punk is a shell item (IShellItem) or any object that can produce an IDList
    // using SHGetIDListFromObject()
    // uFlags contains SBSP_ flag values
    HRESULT BrowseToObject([in] IUnknown *punk, [in] UINT uFlags);

    // populate from a given data source
    // punk can be an IDataObject or anything that can be used with INamespaceWalk
    HRESULT FillFromObject([in, unique] IUnknown *punk, [in] EXPLORER_BROWSER_FILL_FLAGS dwFlags);

    HRESULT RemoveAll();

    // return the current view object on IShellView or IFolderView or related interface
    HRESULT GetCurrentView([in] REFIID riid, [out, iid_is(riid)] void **ppv);
}

//
//  This allows you to set the accessible name on COM objects that function as UI elements
//
[
    uuid(95A391C5-9ED4-4c28-8401-AB9E06719E11),
    object,
]
interface IAccessibleObject : IUnknown
{
    HRESULT SetAccessibleName([in, string] LPCWSTR pszName);
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
[
    object,
    uuid(96E5AE6D-6AE1-4b1c-900C-C6480EAA8828),
    pointer_default(unique)
]
interface IResultsFolder : IUnknown
{
    HRESULT AddItem([in] IShellItem *psi);

    [local]
    HRESULT AddIDList(
        [in, annotation("__in")] PCIDLIST_ABSOLUTE pidl,
        [out, annotation("__deref_opt_out")] PITEMID_CHILD *ppidlAdded);

    [call_as(AddIDList)]
    HRESULT RemoteAddIDList(
        [in] PCIDLIST_ABSOLUTE pidl,
        [out] PITEMID_CHILD *ppidlAdded);

    HRESULT RemoveItem([in] IShellItem *psi);

    HRESULT RemoveIDList([in] PCIDLIST_ABSOLUTE pidl);

    HRESULT RemoveAll();
}
//cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

// Unknown Object Enumerator
[
    uuid(2c1c7e2e-2d0e-4059-831e-1e6f82335c2e),
    object,
    pointer_default(unique)
]
interface IEnumObjects : IUnknown
{
    [local] HRESULT Next(
        [in, annotation("__in")] ULONG celt,
        [in, annotation("__in")] REFIID riid,
        [out, size_is(celt), length_is(*pceltFetched), iid_is(riid), annotation("__out_ecount_part(celt, *pceltFetched)")] void **rgelt,
        [out, annotation("__out_opt __deref_out_range(0, celt)")] ULONG *pceltFetched);

    [call_as(Next)] HRESULT RemoteNext(
        [in] ULONG celt,
        [in] REFIID riid,
        [out, size_is(celt), length_is(*pceltFetched), iid_is(riid)] void **rgelt,
        [out] ULONG *pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumObjects **ppenum);
}

[v1_enum] enum _OPPROGDLGF
{
    // The flag space includes OPPROGDLG_ and PROGDLG_ values
    // please guarantee they don't conflict. See shlobj.w for PROGDLG_*
    OPPROGDLG_DEFAULT               = 0x00000000,
    OPPROGDLG_ENABLEPAUSE           = 0x00000080,   // Add a pause button (operation can be paused)
    OPPROGDLG_ALLOWUNDO             = 0x00000100,   // The operation can be undone in the dialog.  (The Stop button becomes Undo)
    OPPROGDLG_DONTDISPLAYSOURCEPATH = 0x00000200,   // Don't display the path of source file in progress dialog
    OPPROGDLG_DONTDISPLAYDESTPATH   = 0x00000400,   // Don't display the path of destination file in progress dialog
    OPPROGDLG_NOMULTIDAYESTIMATES   = 0x00000800,   // deprecated - progress dialog no longer displays > 1 day estimates
    OPPROGDLG_DONTDISPLAYLOCATIONS  = 0x00001000,   // Don't display the location line in the progress dialog
};
typedef DWORD OPPROGDLGF;

// Shell Operations Engine Progress Dialog
[
    uuid(0C9FB851-E5C9-43EB-A370-F0677B13874C),
    object,
    pointer_default(unique)
]
interface IOperationsProgressDialog : IUnknown
{
    [v1_enum] enum _PDMODE
    {
        PDM_DEFAULT        = 0x00000000,
        PDM_RUN            = 0x00000001,       // Operation is running
        PDM_PREFLIGHT      = 0x00000002,       // Pre-flight mode, calculating operation time, etc
        PDM_UNDOING        = 0x00000004,       // Operation is rolling back, undo has been selected
        PDM_ERRORSBLOCKING = 0x00000008,       // Only errors remain, error dialogs are blocking progress from completing
        PDM_INDETERMINATE  = 0x00000010,       // The length of the operation is indeterminate, don't show a timer, progressbar is in marquee mode
    };
    typedef DWORD PDMODE;

    typedef [v1_enum] enum PDOPSTATUS
    {
        PDOPS_RUNNING   = 1,       // Operation is running, no user intervention
        PDOPS_PAUSED    = 2,       // Operation has been paused by the user
        PDOPS_CANCELLED = 3,       // Operation has been cancelled by the user - now go undo
        PDOPS_STOPPED   = 4,       // Operation has been stopped by the user - terminate completely
        PDOPS_ERRORS    = 5,       // Operation has gone as far as it can without throwing error dialogs
    } PDOPSTATUS;

    HRESULT StartProgressDialog([in, unique] HWND hwndOwner, [in] OPPROGDLGF flags);

    HRESULT StopProgressDialog();

    // Sets which operation is occuring, and whether we are in pre-flight or undo mode - sets animations, text, etc.
    HRESULT SetOperation([in] SPACTION action);

    HRESULT SetMode([in] PDMODE mode);

    HRESULT UpdateProgress(
       [in] ULONGLONG ullPointsCurrent,     // Progress (in points) we are currently at
       [in] ULONGLONG ullPointsTotal,       // Progress (in points) to go to timer
       [in] ULONGLONG ullSizeCurrent,       // Progress (in bytes) we are currently at
       [in] ULONGLONG ullSizeTotal,         // Progress (in bytes) total
       [in] ULONGLONG ullItemsCurrent,      // Progress (in # of items) we are currently at
       [in] ULONGLONG ullItemsTotal);       // Progress (in # of items) total

    // Used to generate display for "from <item (path)> to <item (path)>", etc.
    HRESULT UpdateLocations(
        [in, unique] IShellItem *psiSource,
        [in, unique] IShellItem *psiTarget,
        [in, unique] IShellItem *psiItem);

    HRESULT ResetTimer();

    HRESULT PauseTimer();

    HRESULT ResumeTimer();

    HRESULT GetMilliseconds([out] ULONGLONG *pullElapsed, [out] ULONGLONG *pullRemaining);

    // Returns running/paused/cancelled, etc.
    HRESULT GetOperationStatus([out] PDOPSTATUS *popstatus);
}

// Handles the thread ID and message information used after cancelling progress UI
[
    uuid(f5b0bf81-8cb5-4b1b-9449-1a159e0c733c),
    object,
    pointer_default(unique),
    local
]
interface IIOCancelInformation : IUnknown
{
    // When the progress UI is cancled by the user, dwThreadID will have
    // 1) any pending or future IO requests canceled using CancelSynchronousIo()
    // 2) uMsgCancel will be posted to the thread to tell it to
    //    exit a wait that it might be in waiting for async IO to complete
    HRESULT SetCancelInformation([in] DWORD dwThreadID, [in] UINT uMsgCancel);
    HRESULT GetCancelInformation([out, annotation("__out_opt")] DWORD *pdwThreadID, [out, annotation("__out_opt")] UINT *puMsgCancel);
}

// Extended FOF_ flags passed to IFileOperation::SetOperationFlags()
// These flags only work with IFileOperation not SHFileOperation.
// other posible FOF_ flags are specified in shellapi.h

cpp_quote("#define FOFX_NOSKIPJUNCTIONS         0x00010000  // Don't avoid binding to junctions (like Task folder, Recycle-Bin)")
cpp_quote("#define FOFX_PREFERHARDLINK          0x00020000  // Create hard link if possible")
cpp_quote("#define FOFX_SHOWELEVATIONPROMPT     0x00040000  // Show elevation prompts when error UI is disabled (use with FOF_NOERRORUI)")
cpp_quote("#define FOFX_EARLYFAILURE            0x00100000  // Fail operation as soon as a single error occurs rather than trying to process other items (applies only when using FOF_NOERRORUI)")
cpp_quote("#define FOFX_PRESERVEFILEEXTENSIONS  0x00200000  // Rename collisions preserve file extns (use with FOF_RENAMEONCOLLISION)")
cpp_quote("#define FOFX_KEEPNEWERFILE           0x00400000  // Keep newer file on naming conflicts")
cpp_quote("#define FOFX_NOCOPYHOOKS             0x00800000  // Don't use copy hooks")
cpp_quote("#define FOFX_NOMINIMIZEBOX           0x01000000  // Don't allow minimizing the progress dialog")
cpp_quote("#define FOFX_MOVEACLSACROSSVOLUMES   0x02000000  // Copy security information when performing a cross-volume move operation")
cpp_quote("#define FOFX_DONTDISPLAYSOURCEPATH   0x04000000  // Don't display the path of source file in progress dialog")
cpp_quote("#define FOFX_DONTDISPLAYDESTPATH     0x08000000  // Don't display the path of destination file in progress dialog")
cpp_quote("#define FOFX_REQUIREELEVATION        0x10000000  // User expects the elevation; don't show a dialog to confirm")
cpp_quote("#define FOFX_COPYASDOWNLOAD          0x40000000  // Show Downloading instead of Copying")
cpp_quote("#define FOFX_DONTDISPLAYLOCATIONS    0x80000000  // Hides the locations line in the progress dialog")

// Shell Copy/Move/Rename/Delete/Link/ApplyProperties Operation Handler
[
    uuid(947aab5f-0a5c-4c13-b4d6-4bf7836fc9f8),
    object,
    pointer_default(unique)
]
interface IFileOperation : IUnknown
{
    // 1) (Optional) Set up your event sink.
    HRESULT Advise([in] IFileOperationProgressSink *pfops, [out] DWORD *pdwCookie);

    HRESULT Unadvise([in] DWORD dwCookie);

    // 2) Set operation state
    // FOF_ flags (defined in shellapi.h) and FOFX_ flags are passed here
    // if not specified the default flags are FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR
    HRESULT SetOperationFlags([in] DWORD dwOperationFlags);

    HRESULT SetProgressMessage([in, string] LPCWSTR pszMessage);

    HRESULT SetProgressDialog([in] IOperationsProgressDialog *popd);

    HRESULT SetProperties([in] IPropertyChangeArray *pproparray);

    HRESULT SetOwnerWindow([in] HWND hwndOwner);

    // 3) Specify operations to take on given items.
    // FooItem takes an IShellItem*.
    // FooItems takes an IShellItem*, an IEnumShellItems* or an IDataObject*.
    HRESULT ApplyPropertiesToItem([in] IShellItem *psiItem);

    HRESULT ApplyPropertiesToItems([in] IUnknown *punkItems);

    HRESULT RenameItem(
        [in] IShellItem *psiItem,
        [in, string] LPCWSTR pszNewName,
        [in, unique] IFileOperationProgressSink *pfopsItem);

    HRESULT RenameItems(
        [in] IUnknown *pUnkItems,
        [in, string] LPCWSTR pszNewName);

    HRESULT MoveItem(
        [in] IShellItem *psiItem,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszNewName,
        [in, unique] IFileOperationProgressSink *pfopsItem);

    HRESULT MoveItems(
        [in] IUnknown *punkItems,
        [in] IShellItem *psiDestinationFolder);

    HRESULT CopyItem(
        [in] IShellItem *psiItem,
        [in] IShellItem *psiDestinationFolder,
        [in, unique, string] LPCWSTR pszCopyName,
        [in, unique] IFileOperationProgressSink *pfopsItem);

    HRESULT CopyItems(
        [in] IUnknown *punkItems,
        [in] IShellItem *psiDestinationFolder);

    HRESULT DeleteItem(
        [in] IShellItem *psiItem,
        [in, unique] IFileOperationProgressSink *pfopsItem);

    HRESULT DeleteItems([in] IUnknown *punkItems);

    HRESULT NewItem(
        [in] IShellItem *psiDestinationFolder,
        [in] DWORD dwFileAttributes,
        [in, unique, string] LPCWSTR pszName,
        [in, unique, string] LPCWSTR pszTemplateName,
        [in, unique] IFileOperationProgressSink *pfopsItem);

    // 4) Perform operations.
    HRESULT PerformOperations();

    // 5) Were any operations aborted?
    HRESULT GetAnyOperationsAborted([out] BOOL *pfAnyOperationsAborted);
}

[
    uuid(a6087428-3be3-4d73-b308-7c04a540bf1a),
    object,
    pointer_default(unique)
]
interface IObjectProvider : IUnknown
{
    // IObjectProvider is similar to IServiceProvider except that it
    // does not imply that unhandled/unknown requests should be forwarded,
    // as IServiceProvider does. the object being queired for is identified
    // by guidObject, usually named as OID_XXX
    HRESULT QueryObject([in] REFGUID guidObject, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut);
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

// shell name space walking callback interface"),
[
    uuid(d92995f8-cf5e-4a76-bf59-ead39ea2b97e),
]
interface INamespaceWalkCB : IUnknown
{
    // called for every non folder item found in the folder. these items are reported
    // before any of the folders are returned via EnterFolder(). this is a bredth first
    // walk of the name space
    HRESULT FoundItem([in] IShellFolder *psf, [in] PCUITEMID_CHILD pidl);

    // this is called for ever sub folder found below the punkToWalk input
    // it is not called for any folders specified directly in the input
    //
    // for every folder this is called after all of the items in the folder have
    // been reported via FoundItem()
    //
    // return:
    //      S_OK to continue recursing
    //      S_FALSE to skip this folder but continue
    //      FAILED() (HRESULT_FROM_WIN32(ERROR_CANCELLED)) to stop the whole walk
    HRESULT EnterFolder([in] IShellFolder *psf, [in] PCUITEMID_CHILD pidl);

    // matches the EnterFolder() calls, but since folders can nest this
    // other folders may be entered and left before the matching call is made
    HRESULT LeaveFolder([in] IShellFolder *psf, [in] PCUITEMID_CHILD pidl);

    HRESULT InitializeProgressDialog([out, string] LPWSTR *ppszTitle, [out, string] LPWSTR *ppszCancel);
}

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

[
    uuid(7ac7492b-c38e-438a-87db-68737844ff70),
]
interface INamespaceWalkCB2 : INamespaceWalkCB
{
    HRESULT WalkComplete([in] HRESULT hr);
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

// shell name space walk, used to expand data objects, views or recurse folders
[
    uuid(57ced8a7-3f4a-432c-9350-30f24483f74f),
]
interface INamespaceWalk : IUnknown
{
    typedef [v1_enum] enum
    {
        NSWF_DEFAULT                        = 0x00000000,
        NSWF_NONE_IMPLIES_ALL               = 0x00000001,
        NSWF_ONE_IMPLIES_ALL                = 0x00000002,
        NSWF_DONT_TRAVERSE_LINKS            = 0x00000004,   // don't traverse the targets of link items (items with SFGAO_LINK)
        NSWF_DONT_ACCUMULATE_RESULT         = 0x00000008,   // don't store the results of the walk, GetIDArrayResult() will fail if called

        // for items with both SFGAO_FOLDER and SFGAO_STREAM discovered via the walk 
        // (as opposed to those passed as the input) for example .zip, .search-ms and .library-ms files
        // traverse through them and find the items they reference. this will result in
        // EnterFolder()/LeaveFolder() callbacks instead of FoundItem()
        NSWF_TRAVERSE_STREAM_JUNCTIONS      = 0x00000010,

        NSWF_FILESYSTEM_ONLY                = 0x00000020,   // only return file system items (SFGAO_FILESYSTEM)
        NSWF_SHOW_PROGRESS                  = 0x00000040,   // display the progress dialog while walking
        NSWF_FLAG_VIEWORDER                 = 0x00000080,   // order the items based on the view order that might be different from the default sort
        NSWF_IGNORE_AUTOPLAY_HIDA           = 0x00000100,
        NSWF_ASYNC                          = 0x00000200,   // run the walk on a background thread
        NSWF_DONT_RESOLVE_LINKS             = 0x00000400,   // avoid the expense of resolving links, means link targets might not be up to date
        NSWF_ACCUMULATE_FOLDERS             = 0x00000800,
        NSWF_DONT_SORT                      = 0x00001000,   // Don't maintain sort order of items
        NSWF_USE_TRANSFER_MEDIUM            = 0x00002000,   // Use SHCONTF_STORAGE in enumerations

        // for items with both SFGAO_FOLDER and SFGAO_STREAM passed to the walk
        // (as opposed to those discovered by walking), for example .zip, .search-ms and .library-ms files
        // do not traverse them, instead treat them as items. this will result in
        // FoundItem() callbacks instead of EnterFolder()/LeaveFolder()
        NSWF_DONT_TRAVERSE_STREAM_JUNCTIONS = 0x00004000,
    }  NAMESPACEWALKFLAG;

    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(NAMESPACEWALKFLAG)")

    // punkToWalk can be
    //      a punkSite that QueryService(SID_SFolderView, IFolderView) can discover
    //      IShellFolder
    //      IDataObject
    //      IParentAndItem (thus supports CLSID_ShellItem/IShellItem)
    //      IEnumFullIDList
    //      IShellItem
    //      IShellItemArray
    HRESULT Walk(
        [in] IUnknown *punkToWalk,
        [in] DWORD /* NAMESPACEWALKFLAG */ dwFlags,
        [in] int cDepth,
        [in, unique] INamespaceWalkCB *pnswcb);

    HRESULT GetIDArrayResult(
        [out] UINT *pcItems,
        [out, size_is( , *pcItems)] PIDLIST_ABSOLUTE **prgpidl);
}

cpp_quote("#endif  // NTDDI_WINXP || (_WIN32_IE >= _WIN32_IE_IE70)")

cpp_quote("__inline void FreeIDListArray(__in_ecount(cItems) PIDLIST_RELATIVE *ppidls, UINT cItems)")
cpp_quote("{                                        ")
cpp_quote("     UINT i;                             ")
cpp_quote("     for (i = 0; i < cItems; i++)        ")
cpp_quote("     {                                   ")
cpp_quote("         CoTaskMemFree(ppidls[i]);       ")
cpp_quote("     }                                   ")
cpp_quote("     CoTaskMemFree(ppidls);              ")
cpp_quote("}                                        ")
cpp_quote("#if defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)")
cpp_quote("__inline void FreeIDListArrayFull(__in_ecount(cItems) PIDLIST_ABSOLUTE *ppidls, UINT cItems)")
cpp_quote("{                                        ")
cpp_quote("     for (UINT i = 0; i < cItems; i++)   ")
cpp_quote("     {                                   ")
cpp_quote("         CoTaskMemFree(ppidls[i]);       ")
cpp_quote("     }                                   ")
cpp_quote("     CoTaskMemFree(ppidls);              ")
cpp_quote("}                                        ")
cpp_quote("__inline void FreeIDListArrayChild(__in_ecount(cItems) PITEMID_CHILD *ppidls, UINT cItems)")
cpp_quote("{                                        ")
cpp_quote("     for (UINT i = 0; i < cItems; i++)   ")
cpp_quote("     {                                   ")
cpp_quote("         CoTaskMemFree(ppidls[i]);       ")
cpp_quote("     }                                   ")
cpp_quote("     CoTaskMemFree(ppidls);              ")
cpp_quote("}                                        ")
cpp_quote("#else //  defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)")
cpp_quote("#define FreeIDListArrayFull FreeIDListArray")
cpp_quote("#define FreeIDListArrayChild FreeIDListArray")
cpp_quote("#endif //  defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)")


//
//  Flags for IAutoCompleteDropDown::GetDropDownStatus
//
cpp_quote("#define ACDD_VISIBLE        0x0001")

[
    uuid(3CD141F4-3C6A-11d2-BCAA-00C04FD929DB),
    object,
    pointer_default(unique)
]
interface IAutoCompleteDropDown : IUnknown
{
    HRESULT GetDropDownStatus(
        [out] DWORD *pdwFlags,
        [out, string] LPWSTR *ppwszString);

    HRESULT ResetEnumerator();
}

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE40)")

//-------------------------------------------------------------------------
//
// IBandSite interface
//
//   This interface provides methods to get or set bandsite information.
//
// [Member functions]
//
// IBandSite::AddBand(punk)
//   Add a band to the bandsite.  Returns the band ID in ShortFromResult(hres).
//
// IBandSite::EnumBands(uBand, *pdwBandID)
//   Enumerate the bands. If uBand is -1, pdwBandID is ignored and this
//   method returns the count of bands in the bandsite.  Call this method
//   with uBand starting at 0 to begin enumerating.  Returns S_OK and the
//   band ID in *pdwBandID of the next band.
//
// IBandSite::QueryBand(dwBandID, ppstb, pdwState, pszName, cchName)
//   Get info about a band.
//
// IBandSite::SetBandState(dwBandID, dwState)
//   Set the band's state.
//
// IBandSite::RemoveBand(dwBandID)
//   Remove the band.
//
// IBandSite::GetBandObject(dwBandID, riid, ppv)
//   Get an object that support riid for the band.
//
// IBandSite::GetBandSiteInfo(pbsinfo)
//   Get info about the bandsite.
//
// IBandSite::SetBandSiteInfo(pbsinfo)
//   Set info about the bandsite.
//
//-------------------------------------------------------------------------

cpp_quote("#include <pshpack8.h>")

typedef struct tagBANDSITEINFO
{
    DWORD       dwMask;         // BSIM_* flags
    DWORD       dwState;        // BSSF_* flags
    DWORD       dwStyle;        // BSIS_* flags
} BANDSITEINFO;

cpp_quote("#include <poppack.h>")   // Return to byte packing


enum tagBANDSITECID {
    BSID_BANDADDED,
    BSID_BANDREMOVED,
};

// Field mask
cpp_quote("#define BSIM_STATE          0x00000001")
cpp_quote("#define BSIM_STYLE          0x00000002")

// State flags
cpp_quote("#define BSSF_VISIBLE        0x00000001")
cpp_quote("#define BSSF_NOTITLE        0x00000002")
cpp_quote("#define BSSF_UNDELETEABLE   0x00001000")

// Style flags
cpp_quote("#define BSIS_AUTOGRIPPER               0x00000000")
cpp_quote("#define BSIS_NOGRIPPER                 0x00000001")
cpp_quote("#define BSIS_ALWAYSGRIPPER             0x00000002")
cpp_quote("#define BSIS_LEFTALIGN                 0x00000004")
cpp_quote("#define BSIS_SINGLECLICK               0x00000008")
cpp_quote("#define BSIS_NOCONTEXTMENU             0x00000010")
cpp_quote("#define BSIS_NODROPTARGET              0x00000020")
cpp_quote("#define BSIS_NOCAPTION                 0x00000040")
cpp_quote("#define BSIS_PREFERNOLINEBREAK         0x00000080")
cpp_quote("#define BSIS_LOCKED                    0x00000100")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("#define BSIS_PRESERVEORDERDURINGLAYOUT 0x00000200")
cpp_quote("#define BSIS_FIXEDORDER                0x00000400")
cpp_quote("#endif  // _WIN32_IE_IE70")


cpp_quote("#define SID_SBandSite IID_IBandSite")
cpp_quote("#define CGID_BandSite IID_IBandSite")

[
    object,
    uuid(4CF504B0-DE96-11D0-8B3F-00A0C911E8E5)
]
interface IBandSite : IUnknown
{
    HRESULT AddBand([in] IUnknown* punk);

    HRESULT EnumBands(
        [in] UINT uBand,
        [out] DWORD* pdwBandID);

    [local]
    HRESULT QueryBand(
        [in, annotation("__in")] DWORD dwBandID,
        [out, annotation("__deref_opt_out")] IDeskBand** ppstb,
        [out, annotation("__out_opt")] DWORD* pdwState,
        [out, string, size_is(cchName), annotation("__out_ecount_opt(cchName)")] LPWSTR pszName,
        [in, annotation("__in")] int cchName);

    [call_as(QueryBand)]
    HRESULT RemoteQueryBand(
        [in] DWORD dwBandID,
        [out] IDeskBand** ppstb,
        [out] DWORD* pdwState,
        [out, string, size_is(cchName)] LPWSTR pszName,
        [in] int cchName);

    HRESULT SetBandState(
        [in] DWORD dwBandID,
        [in] DWORD dwMask,
        [in] DWORD dwState);

    HRESULT RemoveBand([in] DWORD dwBandID);

    HRESULT GetBandObject(
        [in] DWORD dwBandID,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT SetBandSiteInfo([in] const BANDSITEINFO *pbsinfo);

    HRESULT GetBandSiteInfo([in, out] BANDSITEINFO *pbsinfo);
}

cpp_quote("#endif // _WIN32_IE_IE40")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

// simple interface for showing a window
[
    uuid(b4db1657-70d7-485e-8e3e-6fcb5a5c1802),
    object,
    pointer_default(unique)
]
interface IModalWindow : IUnknown
{
    [local] HRESULT Show([in, unique, annotation("__in_opt")] HWND hwndOwner);

    [call_as(Show)] HRESULT RemoteShow([in, unique] HWND hwndOwner);
}

// the cd burning wizard extension sets return codes through a property bag
// to tell the main wizard whether it should stop or keep going
cpp_quote("#define PROPSTR_EXTENSIONCOMPLETIONSTATE L\"ExtensionCompletionState\"")
enum tagCDBURNINGEXTENSIONRET
{
    CDBE_RET_DEFAULT          = 0x00000000,
    CDBE_RET_DONTRUNOTHEREXTS = 0x00000001,
    CDBE_RET_STOPWIZARD       = 0x00000002,
};
cpp_quote("#define SID_CDWizardHost IID_ICDBurnExt")

[v1_enum] enum _CDBE_ACTIONS
{
    CDBE_TYPE_MUSIC = 0x00000001,
    CDBE_TYPE_DATA  = 0x00000002,
    CDBE_TYPE_ALL   = (int) 0xFFFFFFFF
};
typedef DWORD CDBE_ACTIONS;

// add-ons for cd burning
[
    uuid(2271dcca-74fc-4414-8fb7-c56b05ace2d7)
]
interface ICDBurnExt : IUnknown
{
    HRESULT GetSupportedActionTypes([out] CDBE_ACTIONS *pdwActions);
}

cpp_quote("#endif  // NTDDI_WINXP")

// New for XP, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")
[
    uuid(0811AEBE-0B87-4C54-9E72-548CF649016B),
    object,
    pointer_default(unique)
]
interface IContextMenuSite : IUnknown
{
    HRESULT DoContextMenuPopup(
        [in] IUnknown* punkContextMenu,
        [in] UINT fFlags,
        [in] POINT pt);
}
//cpp_quote("#endif  // NTDDI_WINXP")

// New for XP, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

[
    uuid(61E00D45-8FFF-4e60-924E-6537B61612DD),
    object,
    pointer_default(unique),
    local
]
interface IEnumReadyCallback : IUnknown
{
    HRESULT EnumReady();
};

// interface between CDefView and clients like the NSC which will try to share enumeration with the view
[
    uuid(8C8BF236-1AEC-495f-9894-91D57C3C686F),
    local
]
interface IEnumerableView : IUnknown
{
    HRESULT SetEnumReadyCallback([in, annotation("__in")] IEnumReadyCallback *percb);

    HRESULT CreateEnumIDListFromContents(
        [in, annotation("__in")] PCIDLIST_ABSOLUTE pidlFolder,
        [in, annotation("__in")] DWORD dwEnumFlags,
        [out, annotation("__deref_out")] IEnumIDList **ppEnumIDList);
}

// QueryService id find the enumerable view.  One case where the QS may fail is if the view is holding on to unrealized items (requires possible I/O to get the real item).
cpp_quote("#define SID_EnumerableView IID_IEnumerableView")
//cpp_quote("#endif  // NTDDI_WINXP")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP) || (_WIN32_IE >= _WIN32_IE_IE70)")

// supports inserting an item into a folder
[
    uuid(D2B57227-3D23-4b95-93C0-492BD454C356),
    object,
    local
]
interface IInsertItem : IUnknown
{
    HRESULT InsertItem([in, annotation("__in")] PCUIDLIST_RELATIVE pidl);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

//-------------------------------------------------------------------------
//
// IMenuBand interface
//
//   This interface provides methods the menuband (CLSID_MenuBand)
//  to receive pertinent messages.
//
// [Member functions]
//
// IMenuBand::IsMenuMessage(pmsg)
//   A message pump calls this function to see if any messages need
//   to be redirected to this object.  If this returns S_OK, the
//   message loop should not call TranslateMessage or DispatchMessage.
//   If this returns E_FAIL, the menu has exited menu mode and is ready
//   to be destroyed.
//
// IMenuBand::TranslateMenuMessage(pmsg, plRet)
//   Offers the object an opportunity to translate messages.  The
//   parent window proc must call this method for every message (not
//   the message pump).  The message, wParam, and lParam should be
//   delivered to this method in *pmsg.  This method may change the
//   values of pmsg->wParam or pmsg->lParam, in which case these changes
//   should be forwarded on.
//
//   This method is required because some modal message pumps (like the one
//   in TrackPopupMenu) do not give an opportunity to call a custom
//   TranslateAccelerator method like IInputObject::TranslateAcceleratorIO.
//
//   TranslateMenuMessage returns S_OK if the message was handled and
//   should be eaten.  *plRet is not touched if this returns S_FALSE.
//
//
//-------------------------------------------------------------------------

[
    uuid(568804CD-CBD7-11d0-9816-00C04FD91972),
    object,
    pointer_default(unique),
    local
]
interface IMenuBand : IUnknown
{
    // CmdIDs for the IOleCommandTarget Group: CGID_MenuBandHandler (defined in shguidp.h)
    enum tagMENUBANDHANDLERCID {
        MBHANDCID_PIDLSELECT    = 0,         // A PIDL from a menuband was selected
    };

    HRESULT IsMenuMessage([in, annotation("__in")] MSG* pmsg);

    HRESULT TranslateMenuMessage(
        [in, out, annotation("__inout")] MSG* pmsg,
        [out, annotation("__out")] LRESULT* plRet);
}

[
    object,
    uuid(47c01f95-e185-412c-b5c5-4f27df965aea),     // IID_IFolderBandPriv
    pointer_default(unique)
]
interface IFolderBandPriv : IUnknown
{
    HRESULT SetCascade([in] BOOL fCascade);

    HRESULT SetAccelerators([in] BOOL fAccelerators);

    HRESULT SetNoIcons([in] BOOL fNoIcons);

    HRESULT SetNoText([in] BOOL fNoText);
}

// callback objects for CRegTreeOptions items
[
    uuid(A9521922-0812-4d44-9EC3-7FD38C726F3D),
    local
]
interface IRegTreeItem : IUnknown
{
    HRESULT GetCheckState([out, annotation("__out")] BOOL *pbCheck);

    HRESULT SetCheckState([in, annotation("__in")] BOOL bCheck);
}

// image recompression object, given the cx, cy and a quality that we need go through the steps
// of creating a stream that we can give to somebody containing an image that size.  if the
// image is < that size then return S_FALSE.

// Image Recompression Object
[
    uuid(505f1513-6b3e-4892-a272-59f8889a4d3e),
    pointer_default(unique),
    object
]
interface IImageRecompress : IUnknown
{
    HRESULT RecompressImage(
        [in] IShellItem *psi,
        [in] int cx,
        [in] int cy,
        [in] int iQuality,
        [in] IStorage *pstg,
        [out] IStream **ppstrmOut);
}


cpp_quote("#endif  // NTDDI_WINXP")
cpp_quote("#endif  // NTDDI_WINXP) || (_WIN32_IE >= _WIN32_IE_IE70)")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE60)")

[
    uuid(EB0FE173-1A3A-11D0-89B3-00A0C90A90AC),
    object,
    pointer_default(unique),
    local
]
interface IDeskBar : IOleWindow
{
    HRESULT SetClient([in, annotation("__in")] IUnknown* punkClient);

    HRESULT GetClient([out, annotation("__deref_out")] IUnknown** ppunkClient);

    HRESULT OnPosRectChangeDB([in, annotation("__in")] RECT *prc);
}

//-------------------------------------------------------------------------
//
// IMenuPopup interface
//
//   This interface provides methods to navigate thru a menu.
//
// [Member functions]
//
// IMenuPopup::Popup(ppt, prcExclude, dwFlags)
//   Invoke the menu, located at the point *ppt (in screen coordinates).
//   The optional prcExclude points to the rectangle to exclude when
//   positioning the menu, otherwise it should be NULL.  dwFlags may be:
//
//      MDBPU_SETFOCUS: the menu can take the focus.
//
//   Returns S_OK if the object implements the popup menu as a modeless
//   menu.  Otherwise it returns S_FALSE, and the menu is finished.
//
// IMenuPopup::OnSelect(dwSelectType)
//   This method handles selection notifications.
//
// IMenuPopup::SetSubMenu(pmp, fSet)
//   Sets the given menu bar interface to be the submenu of this
//   object's interface.  Set fSet == FALSE to remove the submenu.
//
//-------------------------------------------------------------------------
[
    uuid(D1E7AFEB-6A2E-11d0-8C78-00C04FD918B4),
    object,
    pointer_default(unique),
    local
]
interface IMenuPopup : IDeskBar
{
    // Type values for IMenuPopup::OnSelect
    enum tagMENUPOPUPSELECT
    {
        MPOS_EXECUTE = 0,           // Execute the selected menu item
        MPOS_FULLCANCEL,            // Cancel the entire menu
        MPOS_CANCELLEVEL,           // Cancel the current cascaded menu
        MPOS_SELECTLEFT,            // select one to the left of the cur selection
        MPOS_SELECTRIGHT,           // select one to the right of the cur selection
        MPOS_CHILDTRACKING          // the child got a tracking select (mouse moved over)
    };

    // Flags for IMenuPopup::Popup
    enum tagMENUPOPUPPOPUPFLAGS
    {
        MPPF_SETFOCUS        = 0x00000001,    // Menu can take the focus
        MPPF_INITIALSELECT   = 0x00000002,    // Select the first item
        MPPF_NOANIMATE       = 0x00000004,    // Do not animate this show
        MPPF_KEYBOARD        = 0x00000010,    // The menu is activated by keyboard
        MPPF_REPOSITION      = 0x00000020,    // Resposition the displayed bar.
        MPPF_FORCEZORDER     = 0x00000040,    // internal: Tells menubar to ignore Submenu positions
        MPPF_FINALSELECT     = 0x00000080,    // Select the last item
        MPPF_TOP             = 0x20000000,    // Popup menu up from point
        MPPF_LEFT            = 0x40000000,    // Popup menu left from point
        MPPF_RIGHT           = 0x60000000,    // Popup menu right from point
        MPPF_BOTTOM          = (int) 0x80000000, // Popup menu below point
        MPPF_POS_MASK        = (int) 0xE0000000, // Menu Position Mask
        MPPF_ALIGN_LEFT      = 0x02000000,    // Default alignment
        MPPF_ALIGN_RIGHT     = 0x04000000     // Popup menu aligned to right of exclude rect
    };
    typedef int MP_POPUPFLAGS;

    HRESULT Popup(
        [in, annotation("__in")] POINTL *ppt,
        [in, unique, annotation("__in_opt")] RECTL *prcExclude,
        [in, annotation("__in")] MP_POPUPFLAGS dwFlags);

    HRESULT OnSelect([in, annotation("__in")] DWORD dwSelectType);

    HRESULT SetSubMenu(
        [in, annotation("__in")] IMenuPopup* pmp,
        [in, annotation("__in")] BOOL fSet);
}

cpp_quote("#endif  // _WIN32_IE_IE60")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

// Constants for the type of usage of an open file
typedef [v1_enum] enum FILE_USAGE_TYPE
{
    FUT_PLAYING,
    FUT_EDITING,
    FUT_GENERIC
} FILE_USAGE_TYPE;

cpp_quote("#define OF_CAP_CANSWITCHTO     0x0001")
cpp_quote("#define OF_CAP_CANCLOSE        0x0002")

[
    uuid(64a1cbf0-3a1a-4461-9158-376969693950),
    pointer_default(unique)
]
interface IFileIsInUse : IUnknown
{
    HRESULT GetAppName([out, string] LPWSTR *ppszName);

    HRESULT GetUsage([out] FILE_USAGE_TYPE *pfut);

    HRESULT GetCapabilities([out] DWORD *pdwCapFlags);

    HRESULT GetSwitchToHWND([out] HWND *phwnd);

    HRESULT CloseFile();
}

interface IFileDialog;

typedef [v1_enum] enum FDE_OVERWRITE_RESPONSE
{
    FDEOR_DEFAULT            = 0, // The application has not handled the event, and the dialog should put up UI asking the user
                                  // whether or not the file should be overwritten and be returned from the dialog
    FDEOR_ACCEPT             = 1, // The application has decided that the file should be returned from the dialog
    FDEOR_REFUSE             = 2, // The application has decided that the file should not be returned from the dialog
} FDE_OVERWRITE_RESPONSE;

typedef [v1_enum] enum FDE_SHAREVIOLATION_RESPONSE
{
    FDESVR_DEFAULT           = 0, // The application has not handled the event.  The dialog will put up UI indicating the file
                                  // is in use, and a different file must be chosen.
    FDESVR_ACCEPT            = 1, // The application has decided that the file should be returned from the dialog
    FDESVR_REFUSE            = 2, // The application has decided that the file should not be returned from the dialog
} FDE_SHAREVIOLATION_RESPONSE;

typedef [v1_enum] enum FDAP
{
    FDAP_BOTTOM              = 0, // The place is added to the bottom of the default list.
    FDAP_TOP                 = 1, // The place is added to the top of the default list.
} FDAP;


//
// Implemented by a client of the common file dialog browser,
//  for notification of events within the dialog.
//
[
    uuid(973510db-7d7f-452b-8975-74a85828d354),
    object,
    pointer_default(unique)
]
interface IFileDialogEvents : IUnknown
{
    HRESULT OnFileOk([in] IFileDialog *pfd);

    HRESULT OnFolderChanging(
        [in] IFileDialog *pfd,
        [in] IShellItem *psiFolder);

    HRESULT OnFolderChange([in] IFileDialog *pfd);

    HRESULT OnSelectionChange([in] IFileDialog *pfd);

    // Note: FOS_SHAREAWARE must be set in IFileDialog::SetOptions in order for this method to be called.
    HRESULT OnShareViolation(
        [in] IFileDialog *pfd,
        [in] IShellItem *psi,
        [out] FDE_SHAREVIOLATION_RESPONSE *pResponse);

    HRESULT OnTypeChange([in] IFileDialog *pfd);

    // Note: FOS_OVERWRITEPROMPT must be set in IFileDialog::SetOptions in order for this method to be called.
    HRESULT OnOverwrite(
        [in] IFileDialog *pfd,
        [in] IShellItem *psi,
        [out] FDE_OVERWRITE_RESPONSE *pResponse);
}

interface IShellItemFilter;

//
// Implemented by the common file dialog browser, used by clients to
//  initialize, show, and get results from the dialog.
//
[
    uuid(42f85136-db7e-439c-85f1-e4075d135fc8),
    object,
    pointer_default(unique)
]
interface IFileDialog : IModalWindow
{
    [v1_enum] enum _FILEOPENDIALOGOPTIONS
    {
        FOS_OVERWRITEPROMPT          = 0x00000002, // (on by default in the save dialog)
        FOS_STRICTFILETYPES          = 0x00000004, // In the save dialog, only allow the user to choose a file that has
                                                   // one of the file extensions provided in SetFileTypes.
        FOS_NOCHANGEDIR              = 0x00000008, // Don't change the current working directory
        FOS_PICKFOLDERS              = 0x00000020, // Invoke the open dialog in folder picking mode.
        FOS_FORCEFILESYSTEM          = 0x00000040, // Ensure that items returned are filesystem items.
        FOS_ALLNONSTORAGEITEMS       = 0x00000080, // Allow choosing items that have no storage.
        FOS_NOVALIDATE               = 0x00000100,
        FOS_ALLOWMULTISELECT         = 0x00000200,
        FOS_PATHMUSTEXIST            = 0x00000800, // (on by default)
        FOS_FILEMUSTEXIST            = 0x00001000, // (on by default in the open dialog and folder picker)
        FOS_CREATEPROMPT             = 0x00002000,
        FOS_SHAREAWARE               = 0x00004000,
        FOS_NOREADONLYRETURN         = 0x00008000, // (on by default in the save dialog)
        FOS_NOTESTFILECREATE         = 0x00010000, // Avoid testing the creation of the chosen file in the save dialog
                                                   // (specifying this flag will circumvent some useful error handling, such as access denied)
        FOS_HIDEMRUPLACES            = 0x00020000, // (not used in Win7)
        FOS_HIDEPINNEDPLACES         = 0x00040000, // Don't display the standard namespace locations in the navigation pane.
                                                   // (generally used along with AddPlace)
        FOS_NODEREFERENCELINKS       = 0x00100000, // Don't treat shortcuts as their target files.
        FOS_DONTADDTORECENT          = 0x02000000, // Don't add the chosen file to the recent documents list (SHAddToRecentDocs)
        FOS_FORCESHOWHIDDEN          = 0x10000000, // Show all files including system and hidden files.
        FOS_DEFAULTNOMINIMODE        = 0x20000000, // (not used in Win7)
        FOS_FORCEPREVIEWPANEON       = 0x40000000
    };
    typedef DWORD FILEOPENDIALOGOPTIONS;

    HRESULT SetFileTypes(
        [in] UINT cFileTypes,
        [in, size_is(cFileTypes)] const COMDLG_FILTERSPEC *rgFilterSpec);

    HRESULT SetFileTypeIndex([in] UINT iFileType);

    HRESULT GetFileTypeIndex([out] UINT *piFileType);

    HRESULT Advise(
        [in] IFileDialogEvents *pfde,
        [out] DWORD *pdwCookie);

    HRESULT Unadvise([in] DWORD dwCookie);

    HRESULT SetOptions([in] FILEOPENDIALOGOPTIONS fos);

    HRESULT GetOptions([out] FILEOPENDIALOGOPTIONS *pfos);

    HRESULT SetDefaultFolder([in] IShellItem *psi);

    HRESULT SetFolder([in] IShellItem *psi);

    HRESULT GetFolder([out] IShellItem **ppsi);

    HRESULT GetCurrentSelection([out] IShellItem **ppsi);

    HRESULT SetFileName([in, string] LPCWSTR pszName);

    HRESULT GetFileName([out, string] LPWSTR *pszName);

    HRESULT SetTitle([in, string] LPCWSTR pszTitle);

    HRESULT SetOkButtonLabel([in, string] LPCWSTR pszText);

    HRESULT SetFileNameLabel([in, string] LPCWSTR pszLabel);

    HRESULT GetResult([out] IShellItem **ppsi);

    HRESULT AddPlace(
        [in] IShellItem *psi,
        [in] FDAP fdap);

    HRESULT SetDefaultExtension([in, string] LPCWSTR pszDefaultExtension);

    HRESULT Close([in] HRESULT hr);

    HRESULT SetClientGuid([in] REFGUID guid);

    HRESULT ClearClientData();

    HRESULT SetFilter([in] IShellItemFilter *pFilter);
}

//
// Additional methods specific to the file save dialog
//
[
    uuid(84bccd23-5fde-4cdb-aea4-af64b83d78ab),
    object,
    pointer_default(unique)
]
interface IFileSaveDialog : IFileDialog
{
    HRESULT SetSaveAsItem([in] IShellItem *psi);

    HRESULT SetProperties([in] IPropertyStore *pStore);

    HRESULT SetCollectedProperties(
        [in] IPropertyDescriptionList *pList,
        [in] BOOL fAppendDefault);

    HRESULT GetProperties([out] IPropertyStore **ppStore);

    HRESULT ApplyProperties(
        [in] IShellItem *psi,
        [in] IPropertyStore *pStore,
        [in, unique] HWND hwnd,
        [in, unique] IFileOperationProgressSink *pSink);
}

//
// Additional methods specific to the file open dialog
// (adding multiselect capability)
//
[
    uuid(d57c7288-d4ad-4768-be02-9d969532d960),
    object,
    pointer_default(unique)
]
interface IFileOpenDialog : IFileDialog
{
    HRESULT GetResults([out] IShellItemArray **ppenum);

    HRESULT GetSelectedItems([out] IShellItemArray **ppsai);
}

typedef [v1_enum] enum CDCONTROLSTATEF
{
    CDCS_INACTIVE       = 0x00000000,
    CDCS_ENABLED        = 0x00000001,
    CDCS_VISIBLE        = 0x00000002,
    CDCS_ENABLEDVISIBLE = 0x00000003,
} CDCONTROLSTATEF;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(CDCONTROLSTATEF)")

// Some facts:
// - Controls are added before the dialog is shown.  Their relative layout is implied by the order in which
//    they are added. Controls may be added below or above the standard set of controls.
//    Controls can not be removed or added afterwards, but they may be hidden or disabled at any time.
//    Their labels may be changed at any time.
// - Some controls are container controls: combobox, toolsmenu, opendropdown, radiogroup.  These may have
//   items added to them.
// - Items with a container control are "immutable", except for their enabled/visible state.  They can be
//    added and removed at will.  There is no ability to position items within a container - they appear in the
//    order they were added.  IDs for items are scoped to their parent control.
// - Container controls have the notion of a "selected item", with the exception of the toolsmenu.
// - radiobuttongroups behave exactly like comboboxes.  The radio buttons within the group are treated exactly
//    like items in a combobox, one of which can be the "selected item".
[
    uuid(e6fdd21a-163f-4975-9c8c-a69f1ba37034),
    object,
    pointer_default(unique)
]
interface IFileDialogCustomize : IUnknown
{
    // Methods for adding or enabling controls. All of these can have their
    // enabled/visible state set, however the default is for them to be enabled and visible,
    // so this parameter has been left off these methods.
    HRESULT EnableOpenDropDown([in] DWORD dwIDCtl);

    HRESULT AddMenu(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszLabel);

    HRESULT AddPushButton(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszLabel);

    HRESULT AddComboBox([in] DWORD dwIDCtl);

    HRESULT AddRadioButtonList([in] DWORD dwIDCtl);

    HRESULT AddCheckButton(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszLabel,
        [in] BOOL bChecked);

    HRESULT AddEditBox(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszText);

    HRESULT AddSeparator([in] DWORD dwIDCtl);

    HRESULT AddText(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszText);

    // Getting/setting attributes on controls on the fly
    HRESULT SetControlLabel(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszLabel);

    HRESULT GetControlState(
        [in] DWORD dwIDCtl,
        [out] CDCONTROLSTATEF *pdwState);

    HRESULT SetControlState(
        [in] DWORD dwIDCtl,
        [in] CDCONTROLSTATEF dwState);

    HRESULT GetEditBoxText(
        [in] DWORD dwIDCtl,
        [out, string] WCHAR **ppszText);

    HRESULT SetEditBoxText(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszText);

    HRESULT GetCheckButtonState(
        [in] DWORD dwIDCtl,
        [out] BOOL *pbChecked);

    HRESULT SetCheckButtonState(
        [in] DWORD dwIDCtl,
        [in] BOOL bChecked);

    // Method for adding items to "container controls" (radiogroup, combobox, opendropdown, toolsmenu)
    HRESULT AddControlItem(
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem,
        [in] LPCWSTR pszLabel);

    // Methods for removing items in the "container controls"
    HRESULT RemoveControlItem(
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem);

    HRESULT RemoveAllControlItems([in] DWORD dwIDCtl);

    // Getting/setting attributes on control items on the fly
    // Items are considered immutable once created, except for their state:
    HRESULT GetControlItemState(
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem,
        [out] CDCONTROLSTATEF *pdwState);

    HRESULT SetControlItemState(
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem,
        [in] CDCONTROLSTATEF dwState);

    // Methods for some "container controls": OpenDropDown, combobox, radiobuttongroup.
    // These methods don't apply to the tools menu.
    // These methods can be called after the dialog has closed, to determine the users final choice.
    // For comboboxes and radiobuttongroups, these methods may also be called while the
    // dialog is showing (which makes no sense for the OpenDropDown).
    HRESULT GetSelectedControlItem(
        [in] DWORD dwIDCtl,
        [out] DWORD *pdwIDItem);

    HRESULT SetSelectedControlItem(
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem); // Not valid for OpenDropDown

    // Controls can be grouped by wrapping their adds in StartVisualGroup/EndVisualGroup
    // Groups have control IDs, and can be disabled/hidden, just like other controls.
    HRESULT StartVisualGroup(
        [in] DWORD dwIDCtl,
        [in, string] LPCWSTR pszLabel);

    HRESULT EndVisualGroup();

    // One control may be marked as appearing prominently in the UI
    HRESULT MakeProminent([in] DWORD dwIDCtl);

    // Set the text of a control item (RadioButton, or item in an OpenDropDown or Menu)
    HRESULT SetControlItemText(
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem,
        [in, string] LPCWSTR pszLabel);
}

// Event notifications from the controls, handled by an interface
// optionally implemented by the same IFileDialogEvents object supplied by the app.
[
    uuid(36116642-D713-4b97-9B83-7484A9D00433),
    object,
    pointer_default(unique)
]
interface IFileDialogControlEvents : IUnknown
{
    // An item in a combobox, toolsmenu, or radiobutton group was selected.
    // (this notification is *not* sent when an item is chosen from the open dropdown,
    //  as the action here is always the same: close the dialog as if the user clicked open.
    //  At that point, the app will then be able to call GetSelectedItem() for the open dropdown, to
    //  obtain the item that was chosen).
    HRESULT OnItemSelected(
        [in] IFileDialogCustomize *pfdc,
        [in] DWORD dwIDCtl,
        [in] DWORD dwIDItem);

    // A pushbutton was clicked.
    HRESULT OnButtonClicked(
        [in] IFileDialogCustomize *pfdc,
        [in] DWORD dwIDCtl);

    // A checkbutton was toggled.
    HRESULT OnCheckButtonToggled(
        [in] IFileDialogCustomize *pfdc,
        [in] DWORD dwIDCtl,
        [in] BOOL bChecked);

    // A combobox, toolsmenu or open dropdown is about to be "dropped down".  At this point,
    // the application may want to update the contents based on the current state of the dialog.
    HRESULT OnControlActivating(
        [in] IFileDialogCustomize *pfdc,
        [in] DWORD dwIDCtl);
}

[
    uuid(61744fc7-85b5-4791-a9b0-272276309b13),
    object,
    pointer_default(unique)
]
interface IFileDialog2 : IFileDialog
{
    // Changing the text on the Cancel button can be useful for a "basket mode" where IFileDialogEvents::OnFileOk
    // is used to accumulate items, and Open/Cancel would be changed to Add/Done for example.
    HRESULT SetCancelButtonLabel([in] LPCWSTR pszLabel);

    // Replaces any items in the navigation pane with this item instead, to guide the user from navigating outside of 
    // this part of the namespace.
    HRESULT SetNavigationRoot([in] IShellItem *psi);
}

typedef [v1_enum] enum ASSOCIATIONLEVEL
{
    AL_MACHINE,
    AL_EFFECTIVE,
    AL_USER,
} ASSOCIATIONLEVEL;

typedef [v1_enum] enum ASSOCIATIONTYPE
{
    AT_FILEEXTENSION,
    AT_URLPROTOCOL,
    AT_STARTMENUCLIENT,
    AT_MIMETYPE,
} ASSOCIATIONTYPE;

// Application File Extension and URL Protocol Registration
[
    object,
    uuid(4e530b0a-e611-4c77-a3ac-9031d022281b),
    pointer_default(unique)
]
interface IApplicationAssociationRegistration : IUnknown
{
    HRESULT QueryCurrentDefault(
        [in, string] LPCWSTR pszQuery,
        [in] ASSOCIATIONTYPE atQueryType,
        [in] ASSOCIATIONLEVEL alQueryLevel,
        [out, string] LPWSTR* ppszAssociation);

    HRESULT QueryAppIsDefault(
        [in, string] LPCWSTR pszQuery,
        [in] ASSOCIATIONTYPE atQueryType,
        [in] ASSOCIATIONLEVEL alQueryLevel,
        [in, string] LPCWSTR pszAppRegistryName,
        [out] BOOL* pfDefault);

    HRESULT QueryAppIsDefaultAll(
        [in] ASSOCIATIONLEVEL alQueryLevel,
        [in, string] LPCWSTR pszAppRegistryName,
        [out] BOOL* pfDefault);

    HRESULT SetAppAsDefault(
        [in, string] LPCWSTR pszAppRegistryName,
        [in, string] LPCWSTR pszSet,
        [in] ASSOCIATIONTYPE atSetType);

    HRESULT SetAppAsDefaultAll(
        [in, string] LPCWSTR pszAppRegistryName);

    HRESULT ClearUserAssociations();
}

// SHCreateAssociationRegistration can be used to create an IApplicationAssociationRegistration
cpp_quote("SHSTDAPI SHCreateAssociationRegistration(__in REFIID riid, __deref_out void **ppv);")

// Application File Extension and URL Protocol Registration UI
[
    object,
    uuid(1f76a169-f994-40ac-8fc8-0959e8874710),
    pointer_default(unique)
]
interface IApplicationAssociationRegistrationUI : IUnknown
{
    HRESULT LaunchAdvancedAssociationUI([in, string] LPCWSTR pszAppRegistryName);
}

cpp_quote("#endif  // NTDDI_VISTA")

// New for XP, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_WINXP)")

//
// Delegate Item IDs are in a partially known format so the delegate (inner) and
// delgating (outer) folders share the pidl contents. the inner folder allocates
// its pidls using the IMalloc provided by the outer folder via SetItemAlloc()
// that pidl must conform to the delegate item format.
//
cpp_quote("#include <pshpack1.h>")

typedef struct DELEGATEITEMID
{
    WORD cbSize;                // size of entire item ID (points to the NULL or next item)
    WORD wOuter;                // Private data owned by the outer folder
    WORD cbInner;               // Size of delegate's data
    BYTE rgb[1];                // Inner folder's data (opaque to outer folder)
                                //   followed by outer folder's data.
} DELEGATEITEMID;

cpp_quote("#include <poppack.h>")

cpp_quote("typedef const UNALIGNED DELEGATEITEMID *PCDELEGATEITEMID;")
cpp_quote("typedef UNALIGNED DELEGATEITEMID *PDELEGATEITEMID;")

// shell name space delegate folder interface
[
    uuid(ADD8BA80-002B-11D0-8F0F-00C04FD7D062),
    object,
    local,
    pointer_default(unique)
]
interface IDelegateFolder : IUnknown
{
    // use to give the delegate folder the IMalloc interface that it
    // needs to use to alloc and free item IDs.
    // These IDs are in the form of DELEGATEITEMIDs
    // and it is the delegates job to pack its data into the pidl
    // in the delegate format
    HRESULT SetItemAlloc([in, annotation("__in")] IMalloc *pmalloc);
}
//cpp_quote("#endif  // NTDDI_WINXP")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE60)")

cpp_quote("// INTERFACE: IBrowserFrameOptions")
cpp_quote("//")
cpp_quote("// This interface was implemented so a browser or host can ask a ShellView/ShelNameSpace what")
cpp_quote("// kind of 'Behavior' is appropriate for that view.")
cpp_quote("//")
cpp_quote("//    IBrowserFrameOptions::GetBrowserOptions()")
cpp_quote("//       dwMask is the logical OR of bits to look for.  pdwOptions is not optional and")
cpp_quote("//       it's return value will always equal or will be a subset of dwMask.")
cpp_quote("//       If the function succeeds, the return value must be S_OK and pdwOptions needs to be filled in.")
cpp_quote("//       If the function fails, pdwOptions needs to be filled in with BFO_NONE.")
cpp_quote("//")

[
    uuid(10DF43C8-1DBE-11d3-8B34-006097DF5BD4),
    object,
    local
]
interface IBrowserFrameOptions : IUnknown
{
    typedef [unique] IBrowserFrameOptions * LPBROWSERFRAMEOPTIONS;

    [v1_enum] enum _BROWSERFRAMEOPTIONS
    {
        BFO_NONE                            = 0x00000000,      // Do nothing.
        BFO_BROWSER_PERSIST_SETTINGS        = 0x00000001,      // Does this item want the browser stream? (Same window position as IE browser windows?)
        BFO_RENAME_FOLDER_OPTIONS_TOINTERNET = 0x00000002,     // Rename "Folder Options" to "Internet Options" in the Tools or View menu?
        BFO_BOTH_OPTIONS                    = 0x00000004,      // Keep both "Folder Options" and "Internet Options" in the Tools or View menu?
        BIF_PREFER_INTERNET_SHORTCUT        = 0x00000008,      // NSE would prefer a .url shortcut over a .lnk shortcut
        BFO_BROWSE_NO_IN_NEW_PROCESS        = 0x00000010,      // Specify this flag if you don't want the "Browse in New Process" via invoking a shortcut.
        BFO_ENABLE_HYPERLINK_TRACKING       = 0x00000020,      // Does this NSE want it's display name tracked to determine when hyperlinks should be tagged as previously used?
        BFO_USE_IE_OFFLINE_SUPPORT          = 0x00000040,      // Use "Internet Explorer"'s offline support?
        BFO_SUBSTITUE_INTERNET_START_PAGE   = 0x00000080,      // Does this NSE want to use the Start Page support?
        BFO_USE_IE_LOGOBANDING              = 0x00000100,      // Use the Brand block in the Toolbar.  (Spinning globe or whatever it is this year)
        BFO_ADD_IE_TOCAPTIONBAR             = 0x00000200,      // Should " - Internet Explorer" be appended to display name in the Captionbar
        BFO_USE_DIALUP_REF                  = 0x00000400,      // Should the DialUp ref count get a ref while the browse is navigated to this location?  This will also enable the ICW and Software update.
        BFO_USE_IE_TOOLBAR                  = 0x00000800,      // Should the IE toolbar be used?
        BFO_NO_PARENT_FOLDER_SUPPORT        = 0x00001000,      // Can you NOT navigate to a parent folder?  Used for Backspace button to parent folder or the View.GoTo.ParentFolder feature.
        BFO_NO_REOPEN_NEXT_RESTART          = 0x00002000,      // Browser windows are NOT reopened the next time the shell boots if the windows were left open on the previous logoff.  Does this NSE want the same feature?
        BFO_GO_HOME_PAGE                    = 0x00004000,      // Add "Home Page" to menu (Go).
        BFO_PREFER_IEPROCESS                = 0x00008000,      // prefers to use IEXPLORE.EXE over EXPLORER.EXE
        BFO_SHOW_NAVIGATION_CANCELLED       = 0x00010000,      // If navigation is aborted, show the "Action Cancelled" HTML page.
        BFO_USE_IE_STATUSBAR                = 0x00020000,      // Use the persisted IE status bar settings
        BFO_QUERY_ALL                       = (int) 0xFFFFFFFF, // Return all values set.
    };
    typedef DWORD BROWSERFRAMEOPTIONS;

    HRESULT GetFrameOptions(
        [in, annotation("__in")] BROWSERFRAMEOPTIONS dwMask,
        [out, annotation("__out")] BROWSERFRAMEOPTIONS * pdwOptions);
}

cpp_quote("#endif  // _WIN32_IE_IE60")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE60SP2)")

typedef [v1_enum] enum NWMF
{
    NWMF_UNLOADING        = 0x00000001,  // The query is occuring during onBeforeUnload or onUnload
    NWMF_USERINITED       = 0x00000002,  // The query is occuring in the context of what trident considers to be a user initiated action
    NWMF_FIRST            = 0x00000004,  // This is the first query since the begining of the last user initiated action
    NWMF_OVERRIDEKEY      = 0x00000008,  // The override key was pressed at the time the query was made
    NWMF_SHOWHELP         = 0x00000010,  // New window is an HTML help window
    NWMF_HTMLDIALOG       = 0x00000020,  // New window is an HTML dialog
    NWMF_FROMDIALOGCHILD  = 0x00000040,  // Called from an HTML dialog - do not show UI in parent window
    NWMF_USERREQUESTED    = 0x00000080,  // There is no doubt the user requested this window (from RClick->Open in New Window, or Shift+Clicked a link)
    NWMF_USERALLOWED      = 0x00000100,  // This popup is the result of the user requesting a replay that resulted in a refresh
    NWMF_FORCEWINDOW      = 0x00010000,  // This popup should be forced to open in a new window
    NWMF_FORCETAB         = 0x00020000,  // This popup should be forced to open in a new tab
    NWMF_SUGGESTWINDOW    = 0x00040000,  // This popup should open in a new window unless user forced pop-ups to a tab
    NWMF_SUGGESTTAB       = 0x00080000,  // This popup should open in a new tab unless user forced pop-ups to a window
    NWMF_INACTIVETAB      = 0x00100000,  // This popup came from an inactive tab
} NWMF;
cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(NWMF)")

// Popup manager interface for WebOC hosts and Trident.
cpp_quote("#define SID_SNewWindowManager IID_INewWindowManager")
[
    uuid(D2BC4C84-3F72-4a52-A604-7BCBF3982CBB),
    object,
    pointer_default(unique)
]
interface INewWindowManager : IUnknown
{
    HRESULT EvaluateNewWindow(
        [in, string] LPCWSTR pszUrl,
        [in, string] LPCWSTR pszName,
        [in, string] LPCWSTR pszUrlContext,
        [in, string] LPCWSTR pszFeatures,
        [in] BOOL fReplace,
        [in] DWORD dwFlags,
        [in] DWORD dwUserActionTime);
}

//-------------------------------------------------------------------------
// IAttachmentExecute
[
    object,
    uuid(73db1241-1e85-4581-8e4f-a81e1d0f8c57),  // IID_IAttachmentExecute
    local,
    pointer_default(unique),
]
interface IAttachmentExecute : IUnknown
{
    typedef [v1_enum] enum ATTACHMENT_PROMPT
    {
        ATTACHMENT_PROMPT_NONE              = 0x0000,
        ATTACHMENT_PROMPT_SAVE              = 0x0001,
        ATTACHMENT_PROMPT_EXEC              = 0x0002,
        ATTACHMENT_PROMPT_EXEC_OR_SAVE      = 0x0003,
    } ATTACHMENT_PROMPT;

    typedef [v1_enum] enum ATTACHMENT_ACTION
    {
        ATTACHMENT_ACTION_CANCEL            = 0x0000,
        ATTACHMENT_ACTION_SAVE              = 0x0001,
        ATTACHMENT_ACTION_EXEC              = 0x0002,
    } ATTACHMENT_ACTION;

    //
    //  IAttachmentExecute - COM object designed to help client applications
    //      safely manage saving and opening attachments for users.
    //      clients are assumed to have some policy/settings already
    //      to determine the support and behavior for attachments.
    //      this API assumes that the client is interactive with the user
    //
    //  ClientTitle - (optional) caller specific title for the prompt
    //    if unset, the prompts come with a default title of "File Download"
    HRESULT SetClientTitle([in, string, annotation("__in")] LPCWSTR pszTitle);

    //  ClientGuid - (optional) for storing user specific settings
    //      someprompts are allowed to be avoided in the future if the user
    //      chooses.  that choice is stored on per-client basis indexed by the ClientGuid
    //
    //      Specific Example: In the User Trust Prompt there is a check box that is checked
    //      by default, but may be unchecked by the user.  this option is stored under the ClientGuid
    //      based on the file type.
    //
    //      ClearClientState() will reset any user options stored on the clients behalf.
    HRESULT SetClientGuid([in, annotation("__in")] REFGUID guid);


    //  EVIDENCE properties

    //  LocalPath - (REQUIRED) path that would be passed to ShellExecute()
    //      if FileName was already used for the Check() and Prompt() calls,
    //      and the LocalPath points to a different handler than predicted,
    //      previous trust may be revoked, and the Policy and User trust re-verified.
    HRESULT SetLocalPath([in, string, annotation("__in")] LPCWSTR pszLocalPath);

    //  FileName - (optional) proposed name (not path) to be used to construct LocalPath
    //  optionally use this if the caller wants to perform Check() before copying
    //  the file to the LocalPath.  (eg, Check() proposed download)
    HRESULT SetFileName([in, string, annotation("__in")] LPCWSTR pszFileName);

    //  Source - (optional) alternate identity path or URL for a file transfer
    //      used as the primary Zone determinant.  if this is NULL default to the Restricted Zone.
    //      may also be used in the Prompt() UI for the "From" field
    //      may also be sent to handlers that can process URLs
    HRESULT SetSource([in, string, annotation("__in")] LPCWSTR pszSource);

    //  Referrer - (optional) Zone determinant for container or link types
    //      only used for Zone/Policy
    //      container formats like ZIP and OLE packager use the Referrer to
    //      indicate indirect inheritance and avoid Zone elevation.
    //      Shortcuts can also use it to limit elevation based on parameters
    HRESULT SetReferrer([in, string, annotation("__in")] LPCWSTR pszReferrer);

    //  CheckPolicy() - examines available evidence and checks the resultant policy
    //      * requires FileName or LocalPath
    //
    //  Returns S_OK for enable
    //          S_FALSE for prompt
    //          FAILURE for disable
    //
    HRESULT CheckPolicy();

    //  Prompt() - application can force UI at an earlier point,
    //      even before the file has been copied to disk
    //      * requires FileName or LocalPath
    HRESULT Prompt(
        [in, annotation("__in")] HWND hwnd,
        [in, annotation("__in")] ATTACHMENT_PROMPT prompt,
        [out, annotation("__out")] ATTACHMENT_ACTION *paction);

    //  Save() - should always be called if LocalPath is in not in a temp dir
    //      * requires valid LocalPath
    //      * called after the file has been copied to LocalPath
    //      * may run virus scanners or other trust services to validate the file.
    //          these services may delete or alter the file
    //      * may attach evidence to the LocalPath
    HRESULT Save();

    //  Execute() - will call Prompt() if necessary, with the EXEC action
    //      * requires valid LocalPath
    //      * called after the file has been copied to LocalPath
    //      * may run virus scanners or other trust services to validate the file.
    //          these services may delete or alter the file
    //      * may attach evidence to the LocalPath
    //
    //      phProcess - if non-NULL Execute() will be synchronous and return an HPROCESS if available
    //                  if null Execute() will be async, implies that you have a message pump and a long lived window
    //
    HRESULT Execute(
        [in, annotation("__in")] HWND hwnd,
        [in, string, annotation("__in")] LPCWSTR pszVerb,
        [out, annotation("__out_opt")] HANDLE *phProcess);

    //   SaveWithUI() - superset of Save() that can show modal error UI, but still does not call Prompt()
    //      * requires valid LocalPath
    //      * called after the file has been copied to LocalPath
    //      * may run virus scanners or other trust services to validate the file.
    //          these services may delete or alter the file
    //      * may attach evidence to the LocalPath
    HRESULT SaveWithUI([in, annotation("__in")] HWND hwnd);

    //  ClearClientState() - removes any state that is stored based on the ClientGuid
    //      * requires SetClientGuid() to be called first
    HRESULT ClearClientState();
}

cpp_quote("#endif  // _WIN32_IE_IE60SP2")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE60)")

cpp_quote("#include <pshpack8.h>")

typedef struct tagSMDATA
{
    DWORD   dwMask;             // SMDM_* values
    DWORD   dwFlags;            // Not used
    HMENU   hmenu;              // Static HMENU portion.
    HWND    hwnd;               // HWND owning the HMENU
    UINT    uId;                // Id of the item in the menu (-1 for menu itself)
    UINT    uIdParent;          // Id of the item spawning this menu
    UINT    uIdAncestor;        // Id of the very top item in the chain of ShellFolders
    IUnknown*    punk;          // IUnkown of the menuband
    PIDLIST_ABSOLUTE pidlFolder;// pidl of the ShellFolder portion
    PUITEMID_CHILD   pidlItem;  // pidl of the item in the ShellFolder portion
    IShellFolder*   psf;        // IShellFolder for the shell folder portion
    void*   pvUserData;         // User defined Data associated with a pane.
} SMDATA, *LPSMDATA;

cpp_quote("// Mask")
cpp_quote("#define SMDM_SHELLFOLDER               0x00000001  // This is for an item in the band")
cpp_quote("#define SMDM_HMENU                     0x00000002  // This is for the Band itself")
cpp_quote("#define SMDM_TOOLBAR                   0x00000004  // Plain toolbar, not associated with a shell folder or hmenu")

cpp_quote("// Flags (bitmask)")
typedef struct tagSMINFO
{
    DWORD   dwMask;     // SMIM_*
    DWORD   dwType;     // SMIT_*
    DWORD   dwFlags;    // SMIF_*
    int     iIcon;
} SMINFO, * PSMINFO;

typedef struct SHCSCHANGENOTIFYSTRUCT
{
    long                lEvent; // Change notify Event
    PCIDLIST_ABSOLUTE   pidl1;  // Pidl 1 Passed in from the Change notify
    PCIDLIST_ABSOLUTE   pidl2;  // Pidl 2 Passed in from the Change notify
} SMCSHCHANGENOTIFYSTRUCT, *PSMCSHCHANGENOTIFYSTRUCT;

cpp_quote("#include <poppack.h>") /* Return to byte packing */

// Mask flags
enum tagSMINFOMASK
{
    SMIM_TYPE           = 0x00000001,
    SMIM_FLAGS          = 0x00000002,
    SMIM_ICON           = 0x00000004
};

// Types for mbiinfo.dwType
enum tagSMINFOTYPE
{
    SMIT_SEPARATOR      = 0x00000001,
    SMIT_STRING         = 0x00000002
};

// Flags for mbiinfo.dwFlags
enum tagSMINFOFLAGS
{
    SMIF_ICON           = 0x00000001,       // Show an icon
    SMIF_ACCELERATOR    = 0x00000002,       // Underline the character marked w/ '&'
    SMIF_DROPTARGET     = 0x00000004,       // Item is a drop target
    SMIF_SUBMENU        = 0x00000008,       // Item has a submenu
    SMIF_CHECKED        = 0x00000020,       // Item has a Checkmark
    SMIF_DROPCASCADE    = 0x00000040,       // Item can cascade out during drag/drop
    SMIF_HIDDEN         = 0x00000080,       // Don't display item
    SMIF_DISABLED       = 0x00000100,       // Should be unselectable. Gray.
    SMIF_TRACKPOPUP     = 0x00000200,       // Should be unselectable. Gray.
    SMIF_DEMOTED        = 0x00000400,       // Display item in "Demoted" state.
    SMIF_ALTSTATE       = 0x00000800,       // Displayed in "Altered State"
    SMIF_DRAGNDROP      = 0x00001000,       // If item that is being dragged hovers over an item for long enough then it SMC_EXECs that item
    SMIF_NEW            = 0x00002000,       // Item is newly-installed or otherwise attractive (XP)
};

cpp_quote("#define SMC_INITMENU            0x00000001  // The callback is called to init a menuband")
cpp_quote("#define SMC_CREATE              0x00000002")
cpp_quote("#define SMC_EXITMENU            0x00000003  // The callback is called when menu is collapsing")
cpp_quote("#define SMC_GETINFO             0x00000005  // The callback is called to return DWORD values")
cpp_quote("#define SMC_GETSFINFO           0x00000006  // The callback is called to return DWORD values")
cpp_quote("#define SMC_GETOBJECT           0x00000007  // The callback is called to get some object")
cpp_quote("#define SMC_GETSFOBJECT         0x00000008  // The callback is called to get some object")
cpp_quote("#define SMC_SFEXEC              0x00000009  // The callback is called to execute an shell folder item")
cpp_quote("#define SMC_SFSELECTITEM        0x0000000A  // The callback is called when an item is selected")
cpp_quote("#define SMC_REFRESH             0x00000010  // Menus have completely refreshed. Reset your state.")
cpp_quote("#define SMC_DEMOTE              0x00000011  // Demote an item")
cpp_quote("#define SMC_PROMOTE             0x00000012  // Promote an item, wParam = SMINV_* flag")
cpp_quote("#define SMC_DEFAULTICON         0x00000016  // Returns Default icon location in wParam, index in lParam")
cpp_quote("#define SMC_NEWITEM             0x00000017  // Notifies item is not in the order stream.")
cpp_quote("#define SMC_CHEVRONEXPAND       0x00000019  // Notifies of a expansion via the chevron")
cpp_quote("#define SMC_DISPLAYCHEVRONTIP   0x0000002A  // S_OK display, S_FALSE not.")
cpp_quote("#define SMC_SETSFOBJECT         0x0000002D  // Called to save the passed object")
cpp_quote("#define SMC_SHCHANGENOTIFY      0x0000002E  // Called when a Change notify is received. lParam points to SMCSHCHANGENOTIFYSTRUCT")
cpp_quote("#define SMC_CHEVRONGETTIP       0x0000002F  // Called to get the chevron tip text. wParam = Tip title, Lparam = TipText Both MAX_PATH")
cpp_quote("#define SMC_SFDDRESTRICTED      0x00000030  // Called requesting if it's ok to drop. wParam = IDropTarget.")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("#define SMC_SFEXEC_MIDDLE       0x00000031  // Same as SFEXEC, but the middle mouse button caused the exec.")
cpp_quote("#define SMC_GETAUTOEXPANDSTATE  0x00000041  // callback returns the default autoexpand state lParam = LPDWORD to recieve flags")
cpp_quote("#define SMC_AUTOEXPANDCHANGE    0x00000042  // Notify that the menu is expanding/contracting")
cpp_quote("#define SMC_GETCONTEXTMENUMODIFIER 0x00000043  // Used to add items to a context menu")
cpp_quote("#define SMC_GETBKCONTEXTMENU    0x00000044  // used to get a context menu to display when user right clicks on the background")
cpp_quote("#define SMC_OPEN                0x00000045  // allows client to overwrite open/explore verb action on an item")

cpp_quote("// Flags for return value from SMC_GETAUTOEXPANDSTATE and SMC_AUTOEXPANDCHANGE:")
cpp_quote("#define SMAE_EXPANDED           0x00000001  // The menu is or should start expanded")
cpp_quote("#define SMAE_CONTRACTED         0x00000002  // The menu is or should start contracted")
cpp_quote("                                            // SMAE_EXPANDED and SMAE_CONTRACTED are mutually exclusive")
cpp_quote("#define SMAE_USER               0x00000004  // Indicates that the menu expansion/contraction is a reflection")
cpp_quote("                                            // of user choice")
cpp_quote("#define SMAE_VALID              0x00000007")
cpp_quote("#endif  // _WIN32_IE_IE70")

[
    uuid(4CA300A1-9B8D-11d1-8B22-00C04FD918D0),
    object,
    pointer_default(unique),
    local // cannot marshal because method has polymorphic parameters
]

interface IShellMenuCallback : IUnknown
{
    // psmd is [in,out] because SMC_MAPACCELERATOR returns a value in uId
    HRESULT CallbackSM(
        [in, out, annotation("__inout")] LPSMDATA psmd,
        [in, annotation("__in")] UINT uMsg,
        [in, annotation("__in")] WPARAM wParam,
        [in, annotation("__in")] LPARAM lParam);
}

//-------------------------------------------------------------------------
//
// IShellMenu interface
//
//-------------------------------------------------------------------------

cpp_quote("#define SMINIT_DEFAULT              0x00000000  // No Options")
cpp_quote("#define SMINIT_RESTRICT_DRAGDROP    0x00000002  // Don't allow Drag and Drop")
cpp_quote("#define SMINIT_TOPLEVEL             0x00000004  // This is the top band.")
cpp_quote("#define SMINIT_CACHED               0x00000010")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")
cpp_quote("#define SMINIT_AUTOEXPAND           0x00000100  // automatically expand/contract menu band")
cpp_quote("#define SMINIT_AUTOTOOLTIP          0x00000200  // regular tooltip support")
cpp_quote("#define SMINIT_DROPONCONTAINER      0x00000400  // allow drop on a container")
cpp_quote("#endif  // _WIN32_IE_IE70")

// These are mutually Exclusive
cpp_quote("#define SMINIT_VERTICAL             0x10000000  // This is a vertical menu")
cpp_quote("#define SMINIT_HORIZONTAL           0x20000000  // This is a horizontal menu    (does not inherit)")

cpp_quote("#define ANCESTORDEFAULT      (UINT)-1")

cpp_quote("#define SMSET_TOP                   0x10000000    // Bias this namespace to the top of the menu")
cpp_quote("#define SMSET_BOTTOM                0x20000000    // Bias this namespace to the bottom of the menu")
cpp_quote("#define SMSET_DONTOWN               0x00000001    // The Menuband doesn't own the non-ref counted object")
                                                  // and should not destroy it.

cpp_quote("#define SMINV_REFRESH        0x00000001")
cpp_quote("#define SMINV_ID             0x00000008")

[
    uuid(EE1F7637-E138-11d1-8379-00C04FD918D0),
    object,
    pointer_default(unique), /* some of our pointers can be NULL (as noted) */
    local
]
interface IShellMenu : IUnknown
{
    HRESULT Initialize(
        [in, unique, annotation("__in_opt")] IShellMenuCallback* psmc,
        [in, annotation("__in")] UINT uId,
        [in, annotation("__in")] UINT uIdAncestor,
        [in, annotation("__in")] DWORD dwFlags);

    HRESULT GetMenuInfo(
        [out, annotation("__deref_opt_out")] IShellMenuCallback** ppsmc,
        [out, annotation("__out_opt")] UINT* puId,
        [out, annotation("__out_opt")] UINT* puIdAncestor,
        [out, annotation("__out_opt")] DWORD* pdwFlags);

    HRESULT SetShellFolder(
        [in, unique, annotation("__in_opt")] IShellFolder* psf,
        [in, unique, annotation("__in_opt")] PCIDLIST_ABSOLUTE pidlFolder,
        [in, unique, annotation("__in_opt")] HKEY hKey,
        [in, annotation("__in")] DWORD dwFlags);

    HRESULT GetShellFolder(
        [out, annotation("__out")] DWORD* pdwFlags,
        [out, annotation("__deref_out")] PIDLIST_ABSOLUTE* ppidl,
        [in] REFIID riid,
        [out, iid_is(riid), annotation("__deref_out")] void** ppv);

    HRESULT SetMenu(
        [in, unique, annotation("__in_opt")] HMENU hmenu,
        [in, unique, annotation("__in_opt")] HWND hwnd,
        [in, annotation("__in")] DWORD dwFlags);

    HRESULT GetMenu(
        [out, annotation("__out_opt")] HMENU* phmenu,
        [out, annotation("__out_opt")] HWND* phwnd,
        [out, annotation("__out_opt")] DWORD* pdwFlags);

    HRESULT InvalidateItem(
        [in, annotation("__in_opt")] LPSMDATA psmd,
        [in, annotation("__in")] DWORD dwFlags);

    HRESULT GetState([out, annotation("__out")] LPSMDATA psmd);

    HRESULT SetMenuToolbar(
        [in, annotation("__in")] IUnknown* punk,
        [in, annotation("__in")] DWORD dwFlags);
}

cpp_quote("#endif  // _WIN32_IE_IE60")

[
    uuid(fce4bde0-4b68-4b80-8e9c-7426315a7388),
    object,
    pointer_default(ref),
    local,
]
interface IShellRunDll : IUnknown
{
    HRESULT Run([in, string, annotation("__in")] LPCWSTR pszArgs);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

typedef [v1_enum] enum KF_CATEGORY
{
    KF_CATEGORY_VIRTUAL     = 1,       // virtual folders, have not file system path
    KF_CATEGORY_FIXED       = 2,       // fixed, predefined OS folders, might be different for different users
    KF_CATEGORY_COMMON      = 3,       // Public folders shared by all users, can be redirected
    KF_CATEGORY_PERUSER     = 4,       // User folders, can be redirected
} KF_CATEGORY;

[v1_enum] enum _KF_DEFINITION_FLAGS
{
    KFDF_LOCAL_REDIRECT_ONLY    = 0x00000002,    // Can only be redirected to a local disk
    KFDF_ROAMABLE               = 0x00000004,    // Can be roamed via PC to PC sync
    KFDF_PRECREATE              = 0x00000008,    // Pre create folder
    KFDF_STREAM                 = 0x00000010,    // folder is actually a file
    KFDF_PUBLISHEXPANDEDPATH    = 0x00000020,    // Expanded path is published in the registry under HKCU
};
typedef DWORD KF_DEFINITION_FLAGS;

[v1_enum] enum _KF_REDIRECT_FLAGS
{
    KF_REDIRECT_USER_EXCLUSIVE      = 0x00000001, // Give user exclusive permission
    KF_REDIRECT_COPY_SOURCE_DACL    = 0x00000002, // Copy the DACL of the source directory to target

    // Ownership checks for the target folder if the folder exists, by default, the API does not do any ownership checks
    KF_REDIRECT_OWNER_USER          = 0x00000004, // The owner of the folder must be the user itself
    KF_REDIRECT_SET_OWNER_EXPLICIT  = 0x00000008, // The owner of any newly created folder will be set explicitly
                                                    // by default if user belongs to Administrators group Administrators will be the owner

    // Check if the redirection is already done, S_OK if yes, S_FALSE if some actions need to be done.
    KF_REDIRECT_CHECK_ONLY          = 0x00000010,

    // Enable user interaction when redirecting
    KF_REDIRECT_WITH_UI             = 0x00000020,

    // CSC related settings
    KF_REDIRECT_UNPIN               = 0x00000040, // Unpin the source folder
    KF_REDIRECT_PIN                 = 0x00000080, // Pin the target folder

    KF_REDIRECT_COPY_CONTENTS       = 0x00000200, // Copy the contents (both files and subfolders) under the known folder
    KF_REDIRECT_DEL_SOURCE_CONTENTS = 0x00000400, // Delete source, valid only if KF_REDIRECT_COPY_CONTENTS set

    KF_REDIRECT_EXCLUDE_ALL_KNOWN_SUBFOLDERS
                                    = 0x00000800, // Exclude all known subfolders from redirection
};
typedef DWORD KF_REDIRECT_FLAGS;

[v1_enum] enum _KF_REDIRECTION_CAPABILITIES
{
    KF_REDIRECTION_CAPABILITIES_ALLOW_ALL               = 0x000000FF, // if any of these flags set this means that
                                                                      // the folder can potentially be redirected unless
                                                                      // any deny flag is set
    KF_REDIRECTION_CAPABILITIES_REDIRECTABLE            = 0x00000001, // the folder can potentially be redirected
                                                                      // currently we only allow redirection for
                                                                      // common and user's folders.
                                                                      // Fixed and virtual can not be redirected

    KF_REDIRECTION_CAPABILITIES_DENY_ALL                = 0x000FFF00, // If any of there flags set then redirection is blocked
    KF_REDIRECTION_CAPABILITIES_DENY_POLICY_REDIRECTED  = 0x00000100, // Folder can not be redirected because it is redirected by group policy
    KF_REDIRECTION_CAPABILITIES_DENY_POLICY             = 0x00000200, // Folder can not be redirected because the policy prohibits redirecting this folder
    KF_REDIRECTION_CAPABILITIES_DENY_PERMISSIONS        = 0x00000400, // Folder can not be redirected because the caller does not have sufficient permissions
};
typedef DWORD KF_REDIRECTION_CAPABILITIES;

typedef struct KNOWNFOLDER_DEFINITION
{
    KF_CATEGORY             category;
    LPWSTR                  pszName;
    LPWSTR                  pszDescription;
    KNOWNFOLDERID           fidParent;
    LPWSTR                  pszRelativePath;
    LPWSTR                  pszParsingName;
    LPWSTR                  pszTooltip;
    LPWSTR                  pszLocalizedName;
    LPWSTR                  pszIcon;
    LPWSTR                  pszSecurity;
    DWORD                   dwAttributes;
    KF_DEFINITION_FLAGS     kfdFlags;
    FOLDERTYPEID            ftidType;
} KNOWNFOLDER_DEFINITION;

// Known Folder Interface
[
    uuid(3AA7AF7E-9B36-420c-A8E3-F77D4674A488),
    object,
    version(1.0),
    pointer_default(ref)
]
interface IKnownFolder : IUnknown
{
    HRESULT GetId([out] KNOWNFOLDERID *pkfid);

    HRESULT GetCategory([out] KF_CATEGORY* pCategory);

    // get the ShellItem (IShellItem or derived interface) for this known folder
    HRESULT GetShellItem(
        [in] DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    HRESULT GetPath(
        [in] DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
        [out, string] LPWSTR *ppszPath);

    HRESULT SetPath(
        [in] DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
        [in, string] LPCWSTR pszPath);

    HRESULT GetIDList(
        [in] DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
        [out] PIDLIST_ABSOLUTE *ppidl);

    HRESULT GetFolderType([out] FOLDERTYPEID *pftid);

    HRESULT GetRedirectionCapabilities([out] KF_REDIRECTION_CAPABILITIES * pCapabilities);

    HRESULT GetFolderDefinition([out] KNOWNFOLDER_DEFINITION *pKFD);
}

// Known Folder Manager
[
    uuid(8BE2D872-86AA-4d47-B776-32CCA40C7018),
    object,
    version(1.0),
    pointer_default(ref)
]
interface IKnownFolderManager : IUnknown
{
    typedef [v1_enum] enum FFFP_MODE
    {
        FFFP_EXACTMATCH,
        FFFP_NEARESTPARENTMATCH,
    } FFFP_MODE;

    HRESULT FolderIdFromCsidl(
        [in] int nCsidl,
        [out] KNOWNFOLDERID *pfid);

    HRESULT FolderIdToCsidl(
        [in] REFKNOWNFOLDERID rfid,
        [out] int *pnCsidl);

    HRESULT GetFolderIds(
        [out, size_is( , *pCount)] KNOWNFOLDERID ** ppKFId,
        [in, out] UINT *pCount);

    HRESULT GetFolder(
        [in] REFKNOWNFOLDERID rfid,
        [out] IKnownFolder **ppkf);

    HRESULT GetFolderByName(
        [in, string] LPCWSTR pszCanonicalName,
        [out] IKnownFolder **ppkf);

    HRESULT RegisterFolder(
        [in] REFKNOWNFOLDERID rfid,
        [in] KNOWNFOLDER_DEFINITION const *pKFD);

    HRESULT UnregisterFolder([in] REFKNOWNFOLDERID rfid);

    HRESULT FindFolderFromPath(
        [in, string] LPCWSTR pszPath,
        [in] FFFP_MODE mode,
        [out] IKnownFolder **ppkf);

    HRESULT FindFolderFromIDList(
        [in] PCIDLIST_ABSOLUTE pidl,
        [out] IKnownFolder **ppkf);

    [local]
    HRESULT Redirect(
        [in, annotation("__in")] REFKNOWNFOLDERID rfid,
        [in, unique, annotation("__in_opt")] HWND hwnd,
        [in, annotation("__in")] KF_REDIRECT_FLAGS flags,
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszTargetPath,
        [in, annotation("__in")] UINT cFolders,
        [in, size_is(cFolders), unique, annotation("__in_ecount_opt(cFolders)")] KNOWNFOLDERID const *pExclusion,
        [out, string, annotation("__deref_opt_out_opt")] LPWSTR* ppszError);

    [call_as(Redirect)]
    HRESULT RemoteRedirect(
        [in] REFKNOWNFOLDERID rfid,
        [in, unique] HWND hwnd,
        [in] KF_REDIRECT_FLAGS flags,
        [in, unique, string] LPCWSTR pszTargetPath,
        [in] UINT cFolders,
        [in, size_is(cFolders), unique] GUID const *pExclusion,
        [out, string] LPWSTR* ppszError);
}

// use this to free the allocated fields in the result from IKnownFolderManager::GetFolderDefinition(&kfd)
cpp_quote("__inline void FreeKnownFolderDefinitionFields(__in KNOWNFOLDER_DEFINITION *pKFD)")
cpp_quote("{")
cpp_quote("    CoTaskMemFree(pKFD->pszName);")
cpp_quote("    CoTaskMemFree(pKFD->pszDescription);")
cpp_quote("    CoTaskMemFree(pKFD->pszRelativePath);")
cpp_quote("    CoTaskMemFree(pKFD->pszParsingName);")
cpp_quote("    CoTaskMemFree(pKFD->pszTooltip);")
cpp_quote("    CoTaskMemFree(pKFD->pszLocalizedName);")
cpp_quote("    CoTaskMemFree(pKFD->pszIcon);")
cpp_quote("    CoTaskMemFree(pKFD->pszSecurity);")
cpp_quote("}")

typedef [v1_enum] enum SHARE_ROLE
{
    SHARE_ROLE_INVALID = -1,
    SHARE_ROLE_READER = 0,
    SHARE_ROLE_CONTRIBUTOR = 1,
    SHARE_ROLE_CO_OWNER = 2,
    SHARE_ROLE_OWNER = 3,
    SHARE_ROLE_CUSTOM = 4,
    SHARE_ROLE_MIXED = 5,
}
SHARE_ROLE;

typedef [v1_enum] enum DEF_SHARE_ID
{
    DEFSHAREID_USERS = 1,
    DEFSHAREID_PUBLIC = 2,
}
DEF_SHARE_ID;

// Sharing Configuration Manager
[
    object,
    uuid(B4CD448A-9C86-4466-9201-2E62105B87AE)
]
interface ISharingConfigurationManager : IUnknown
{
    HRESULT CreateShare(
        [in] DEF_SHARE_ID dsid,
        [in] SHARE_ROLE role);

    HRESULT DeleteShare([in] DEF_SHARE_ID dsid);

    // returns S_OK if the share exists, S_FALSE otherwise
    HRESULT ShareExists([in] DEF_SHARE_ID dsid);

    HRESULT GetSharePermissions(
        [in] DEF_SHARE_ID dsid,
        [out] SHARE_ROLE* pRole);

    HRESULT SharePrinters();

    HRESULT StopSharingPrinters();

    HRESULT ArePrintersShared();
}

cpp_quote("#endif  // NTDDI_VISTA")

[
    object,
    uuid(76e54780-ad74-48e3-a695-3ba9a0aff10d),
    pointer_default(unique),
    local
]
interface IPreviousVersionsInfo : IUnknown
{
    HRESULT AreSnapshotsAvailable(
        [in, string, annotation("__in")] LPCWSTR pszPath,
        [in, annotation("__in")] BOOL fOkToBeSlow,
        [out, annotation("__out")] BOOL *pfAvailable);
}

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

// Base interface from which to derive "related items"
// with specific relationships, and identical method signatures.
//
// Use with
// IShellItem::BindToHandler, BHID_SFObject
// IShellFolder::BindToObject
[
    object,
    uuid(a73ce67a-8ab1-44f1-8d43-d2fcbf6b1cd0),
    pointer_default(unique)
]
interface IRelatedItem : IUnknown
{
    HRESULT GetItemIDList([out] PIDLIST_ABSOLUTE *ppidl);

    HRESULT GetItem([out] IShellItem **ppsi);
}

// Used to obtain the true identity of the item, so it can be
// determined if two items actually represent the same item.
[
    object,
    uuid(7d903fca-d6f9-4810-8332-946c0177e247),
    pointer_default(unique)
]
interface IIdentityName : IRelatedItem
{
}

// Used to obtain the delegate item of an item, where the 
// item is delegating to the underlying "delegate" item.
// Unlike IIdentityName, IDelegateItem only "unwraps" one
// level of aliasing.
[
    object,
    uuid(3c5a1c94-c951-4cb7-bb6d-3b93f30cce93),
    pointer_default(unique)
]
interface IDelegateItem : IRelatedItem
{
}

// If an item represents a snapshot of an item taken at a previous time,
// ICurrentItem will let you obtain the current version of the item.
[
    object,
    uuid(240a7174-d653-4a1d-a6d3-d4943cfbfe3d),
    pointer_default(unique)
]
interface ICurrentItem : IRelatedItem
{
}

// used to find the transfer object. that is the object that should be
// queried and enumerated for copy/move/delete.
[
    object,
    uuid(77f295d5-2d6f-4e19-b8ae-322f3e721ab5),
    pointer_default(unique)
]
interface ITransferMediumItem : IRelatedItem
{
}

// used to find the item that should be used when browsing to this item (used by pagespace control)
[
    object,
    uuid(05edda5c-98a3-4717-8adb-c5e7da991eb1),
    pointer_default(unique)
]
interface IUseToBrowseItem : IRelatedItem
{
}

// IDisplayItem provides the item to show UI on (used by the copy engine dialogs)
[
    object,
    uuid(c6fd5997-9f6b-4888-8703-94e80e8cde3f),
    pointer_default(unique)
]
interface IDisplayItem : IRelatedItem
{
}

// IViewStateIdentityItem is used to provide a canonical persistence item
// This is item for which view customizations will be remembered 
// (example: the orignal folder item minus the search query)
[
    object,
    uuid(9D264146-A94F-4195-9F9F-3BB12CE0C955),
    pointer_default(unique)
]
interface IViewStateIdentityItem : IRelatedItem
{
}

// IPreviewItem provides an item to show in the preview pane
[
    object,
    uuid(36149969-0A8F-49c8-8B00-4AECB20222FB),
    pointer_default(unique)
]
interface IPreviewItem : IRelatedItem
{
}

// and many more to come "related items"...
//
//  "public partner" - like to SharedPics from MyPics
//  "private partner" - link to MyPics from SharedPics
//  "recyle bin root" - where (and if) recycle bin is supported
//  "machine root" - for "open containing machine"

cpp_quote("#endif  // NTDDI_VISTA")

// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
[
    uuid(8a87781b-39a7-4a1f-aab3-a39b9c34a7d9),
    object,
    pointer_default(unique)
]
interface IDestinationStreamFactory : IUnknown
{
    HRESULT GetDestinationStream([out] IStream **ppstm);
}
//cpp_quote("#endif  // NTDDI_VISTA")

[v1_enum] enum _NMCII_FLAGS
{
    NMCII_ITEMS        = 0x0001,
    NMCII_FOLDERS      = 0x0002,
};
typedef int NMCII_FLAGS;

[v1_enum] enum _NMCSAEI_FLAGS
{
    NMCSAEI_SELECT      = 0x0000,
    NMCSAEI_EDIT        = 0x0001,
};
typedef int NMCSAEI_FLAGS;

[
    uuid(dcb07fdc-3bb5-451c-90be-966644fed7b0),
    pointer_default(unique)
]
interface INewMenuClient : IUnknown
{
    HRESULT IncludeItems([out] NMCII_FLAGS *pflags);

    HRESULT SelectAndEditItem(
        [in] PCIDLIST_ABSOLUTE pidlItem,
        [in] NMCSAEI_FLAGS flags);
};

cpp_quote("#define SID_SNewMenuClient   IID_INewMenuClient")

// SID_SCommandBarState: {B99EAA5C-3850-4400-BC33-2CE534048BF8}
cpp_quote("DEFINE_GUID(SID_SCommandBarState, 0xB99EAA5C, 0x3850, 0x4400, 0xBC, 0x33, 0x2C, 0xE5, 0x34, 0x04, 0x8B, 0xF8);")

cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

[
    object,
    uuid(71c0d2bc-726d-45cc-a6c0-2e31c1db2159),
    pointer_default(unique)
]
interface IInitializeWithBindCtx : IUnknown
{
    HRESULT Initialize([in] IBindCtx *pbc);
}

[
    object,
    uuid(2659B475-EEB8-48b7-8F07-B378810F48CF),
    pointer_default(unique)
]
interface IShellItemFilter : IUnknown
{
    HRESULT IncludeItem([in] IShellItem *psi);

    HRESULT GetEnumFlagsForItem(
        [in] IShellItem *psi,
        [out] SHCONTF *pgrfFlags);
}

cpp_quote("#endif  // (_WIN32_IE >= _WIN32_IE_IE70)")

// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

[
    object,
    uuid(028212A3-B627-47e9-8856-C14265554E4F)
]
interface INameSpaceTreeControl : IUnknown
{
    [v1_enum] enum _NSTCSTYLE
    {
        NSTCS_HASEXPANDOS           = 0x00000001,
        NSTCS_HASLINES              = 0x00000002,
        NSTCS_SINGLECLICKEXPAND     = 0x00000004,
        NSTCS_FULLROWSELECT         = 0x00000008,
        NSTCS_SPRINGEXPAND          = 0x00000010,
        NSTCS_HORIZONTALSCROLL      = 0x00000020,
        NSTCS_ROOTHASEXPANDO        = 0x00000040,
        NSTCS_SHOWSELECTIONALWAYS   = 0x00000080,
        NSTCS_NOINFOTIP             = 0x00000200,
        NSTCS_EVENHEIGHT            = 0x00000400,
        NSTCS_NOREPLACEOPEN         = 0x00000800,
        NSTCS_DISABLEDRAGDROP       = 0x00001000,
        NSTCS_NOORDERSTREAM         = 0x00002000,
        NSTCS_RICHTOOLTIP           = 0x00004000,
        NSTCS_BORDER                = 0x00008000,
        NSTCS_NOEDITLABELS          = 0x00010000,
        NSTCS_TABSTOP               = 0x00020000,
        NSTCS_FAVORITESMODE         = 0x00080000,  // temporary
        NSTCS_AUTOHSCROLL           = 0x00100000,
        NSTCS_FADEINOUTEXPANDOS     = 0x00200000,
        NSTCS_EMPTYTEXT             = 0x00400000,  // insert empty text when folder is empty
        NSTCS_CHECKBOXES            = 0x00800000,
        NSTCS_PARTIALCHECKBOXES     = 0x01000000,
        NSTCS_EXCLUSIONCHECKBOXES   = 0x02000000,
        NSTCS_DIMMEDCHECKBOXES      = 0x04000000,
        NSTCS_NOINDENTCHECKS        = 0x08000000,
        NSTCS_ALLOWJUNCTIONS        = 0x10000000,
        NSTCS_SHOWTABSBUTTON        = 0x20000000,
        NSTCS_SHOWDELETEBUTTON      = 0x40000000,
        NSTCS_SHOWREFRESHBUTTON     = (int) 0x80000000,
    };
    typedef DWORD NSTCSTYLE;

    [v1_enum] enum _NSTCROOTSTYLE
    {
        NSTCRS_VISIBLE      = 0x0000,
        NSTCRS_HIDDEN       = 0x0001,
        NSTCRS_EXPANDED     = 0x0002,
    };
    typedef DWORD NSTCROOTSTYLE;

    [v1_enum] enum _NSTCITEMSTATE
    {
        NSTCIS_NONE             = 0x0000,
        NSTCIS_SELECTED         = 0x0001,
        NSTCIS_EXPANDED         = 0x0002,
        NSTCIS_BOLD             = 0x0004,
        NSTCIS_DISABLED         = 0x0008,
        NSTCIS_SELECTEDNOEXPAND = 0x0010,
    };
    typedef DWORD NSTCITEMSTATE;

    typedef [v1_enum] enum NSTCGNI
    {
        NSTCGNI_NEXT            = 0,
        NSTCGNI_NEXTVISIBLE     = 1,
        NSTCGNI_PREV            = 2,
        NSTCGNI_PREVVISIBLE     = 3,
        NSTCGNI_PARENT          = 4,
        NSTCGNI_CHILD           = 5,
        NSTCGNI_FIRSTVISIBLE    = 6,
        NSTCGNI_LASTVISIBLE     = 7,
    } NSTCGNI;

    HRESULT Initialize(
        [in] HWND hwndParent,
        [in, unique] RECT *prc,
        [in] NSTCSTYLE nsctsFlags);

    HRESULT TreeAdvise(
        [in] IUnknown *punk,
        [out] DWORD *pdwCookie);

    HRESULT TreeUnadvise([in] DWORD dwCookie);

    HRESULT AppendRoot(
        [in] IShellItem *psiRoot,
        [in] SHCONTF grfEnumFlags,
        [in] NSTCROOTSTYLE grfRootStyle,
        [in, unique] IShellItemFilter *pif);

    HRESULT InsertRoot(
        [in] int iIndex,
        [in] IShellItem *psiRoot,
        [in] SHCONTF grfEnumFlags,
        [in] NSTCROOTSTYLE grfRootStyle,
        [in, unique] IShellItemFilter *pif);

    HRESULT RemoveRoot([in] IShellItem *psiRoot);

    HRESULT RemoveAllRoots();

    HRESULT GetRootItems([out] IShellItemArray **ppsiaRootItems);

    HRESULT SetItemState(
        [in] IShellItem *psi,
        [in] NSTCITEMSTATE nstcisMask,
        [in] NSTCITEMSTATE nstcisFlags);

    HRESULT GetItemState(
        [in] IShellItem *psi,
        [in] NSTCITEMSTATE nstcisMask,
        [out] NSTCITEMSTATE *pnstcisFlags);

    HRESULT GetSelectedItems([out] IShellItemArray **psiaItems);

    HRESULT GetItemCustomState(
        [in] IShellItem *psi,
        [out] int *piStateNumber);

    HRESULT SetItemCustomState(
        [in] IShellItem *psi,
        [in] int iStateNumber);

    HRESULT EnsureItemVisible([in] IShellItem *psi);

    HRESULT SetTheme([in, string] LPCWSTR pszTheme);

    HRESULT GetNextItem(
        [in, unique] IShellItem *psi,
        [in] NSTCGNI nstcgi,
        [out] IShellItem **ppsiNext);

    HRESULT HitTest(
        [in] POINT *ppt,
        [out] IShellItem **ppsiOut);

    HRESULT GetItemRect(
        [in] IShellItem *psi,
        [out] RECT *prect);

    HRESULT CollapseAll();
}

[
    object,
    uuid(7cc7aed8-290e-49bc-8945-c1401cc9306c),
]
interface INameSpaceTreeControl2 : INameSpaceTreeControl
{
    typedef [v1_enum] enum NSTCSTYLE2
    {
        NSTCS2_DEFAULT                  = 0x00000000,
        NSTCS2_INTERRUPTNOTIFICATIONS   = 0x00000001,
        NSTCS2_SHOWNULLSPACEMENU        = 0x00000002,
        NSTCS2_DISPLAYPADDING           = 0x00000004,
        NSTCS2_DISPLAYPINNEDONLY        = 0x00000008, // Filters items based on PKEY_IsPinnedToNameSpaceTree
        NTSCS2_NOSINGLETONAUTOEXPAND    = 0x00000010, // Prevent auto expansion of singleton nodes in tree
        NTSCS2_NEVERINSERTNONENUMERATED = 0x00000020, // Don't insert non-enumerated (SFGAO_NONENUMERATED) items
    } NSTCSTYLE2;

    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(NSTCSTYLE2)")

    HRESULT SetControlStyle(
               [in] NSTCSTYLE nstcsMask,
               [in] NSTCSTYLE nstcsStyle);

    HRESULT GetControlStyle(
               [in] NSTCSTYLE nstcsMask,
               [out] NSTCSTYLE *pnstcsStyle);

    HRESULT SetControlStyle2(
               [in] NSTCSTYLE2 nstcsMask,
               [in] NSTCSTYLE2 nstcsStyle);

    HRESULT GetControlStyle2(
               [in] NSTCSTYLE2 nstcsMask,
               [out] NSTCSTYLE2 *pnstcsStyle);
}

cpp_quote("#define NSTCS2_ALLMASK (NSTCS2_INTERRUPTNOTIFICATIONS | NSTCS2_SHOWNULLSPACEMENU | NSTCS2_DISPLAYPADDING)")
cpp_quote("#define SID_SNavigationPane IID_INameSpaceTreeControl   // nearest service that you can proffer to")

cpp_quote("#define ISLBUTTON(x) (NSTCECT_LBUTTON == ((x) & NSTCECT_BUTTON))")
cpp_quote("#define ISMBUTTON(x) (NSTCECT_MBUTTON == ((x) & NSTCECT_BUTTON))")
cpp_quote("#define ISRBUTTON(x) (NSTCECT_RBUTTON == ((x) & NSTCECT_BUTTON))")
cpp_quote("#define ISDBLCLICK(x) (NSTCECT_DBLCLICK == ((x) & NSTCECT_DBLCLICK))")

[
    object,
    uuid(93D77985-B3D8-4484-8318-672CDDA002CE),
    local
]
interface INameSpaceTreeControlEvents : IUnknown
{
    [v1_enum] enum _NSTCEHITTEST
    {
        // items up to 0x00ff reflect the TVHITTESTINFO flags
        NSTCEHT_NOWHERE         = 0x0001,
        NSTCEHT_ONITEMICON      = 0x0002,
        NSTCEHT_ONITEMLABEL     = 0x0004,
        NSTCEHT_ONITEMINDENT    = 0x0008,
        NSTCEHT_ONITEMBUTTON    = 0x0010,
        NSTCEHT_ONITEMRIGHT     = 0x0020,
        NSTCEHT_ONITEMSTATEICON = 0x0040,
        NSTCEHT_ONITEM          = 0x0046,
        // items below don't reflect the TVHITTESTINFO flags
        NSTCEHT_ONITEMTABBUTTON = 0x1000,
    };
    typedef DWORD NSTCEHITTEST;

    [v1_enum] enum _NSTCECLICKTYPE
    {
        NSTCECT_LBUTTON    = 0x0001,
        NSTCECT_MBUTTON    = 0x0002,
        NSTCECT_RBUTTON    = 0x0003,
        NSTCECT_BUTTON     = 0x0003,
        NSTCECT_DBLCLICK   = 0x0004,
    };
    typedef DWORD NSTCECLICKTYPE;

    HRESULT OnItemClick(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] NSTCEHITTEST nstceHitTest,
        [in, annotation("__in")] NSTCECLICKTYPE nstceClickType);

    HRESULT OnPropertyItemCommit([in, annotation("__in")] IShellItem *psi);

    HRESULT OnItemStateChanging(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] NSTCITEMSTATE nstcisMask,
        [in, annotation("__in")] NSTCITEMSTATE nstcisState);

    HRESULT OnItemStateChanged(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] NSTCITEMSTATE nstcisMask,
        [in, annotation("__in")] NSTCITEMSTATE nstcisState);

    HRESULT OnSelectionChanged([in, annotation("__in")] IShellItemArray *psiaSelection);

    HRESULT OnKeyboardInput(
        [in, annotation("__in")] UINT uMsg,
        [in, annotation("__in")] WPARAM wParam,
        [in, annotation("__in")] LPARAM lParam);

    HRESULT OnBeforeExpand([in, annotation("__in")] IShellItem *psi);

    HRESULT OnAfterExpand([in, annotation("__in")] IShellItem *psi);

    HRESULT OnBeginLabelEdit([in, annotation("__in")] IShellItem *psi);

    HRESULT OnEndLabelEdit([in, annotation("__in")] IShellItem *psi);

    HRESULT OnGetToolTip(
        [in, annotation("__in")] IShellItem *psi,
        [out, string, size_is(cchTip), annotation("__out_ecount(cchTip)")] LPWSTR pszTip,
        [in, annotation("__in")] int cchTip);

    HRESULT OnBeforeItemDelete([in, annotation("__in")] IShellItem *psi);

    HRESULT OnItemAdded(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] BOOL fIsRoot);

    HRESULT OnItemDeleted(
        [in, annotation("__in")] IShellItem *psi,
        [in, annotation("__in")] BOOL fIsRoot);

    HRESULT OnBeforeContextMenu(
        [in, unique, annotation("__in_opt")] IShellItem *psi,
        [in, annotation("__in")] REFIID riid,
        [out, iid_is(riid), annotation("__deref_out")] void **ppv);

    // psi can only be NULL if NSTCS2_SHOWNULLSPACEMENU is set
    HRESULT OnAfterContextMenu(
        [in, annotation("__in_opt")] IShellItem *psi,
        [in, annotation("__in")] IContextMenu *pcmIn,
        [in, annotation("__in")] REFIID riid,
        [out, iid_is(riid), annotation("__deref_out")] void **ppv);

    HRESULT OnBeforeStateImageChange([in, annotation("__in")] IShellItem *psi);

    HRESULT OnGetDefaultIconIndex(
        [in, annotation("__in")] IShellItem *psi,
        [out, annotation("__out")] int *piDefaultIcon,
        [out, annotation("__out")] int *piOpenIcon);
}

cpp_quote("#define NSTCDHPOS_ONTOP  -1")

[
    object,
    uuid(F9C665D6-C2F2-4c19-BF33-8322D7352F51),
    local
]
interface INameSpaceTreeControlDropHandler : IUnknown
{
    HRESULT OnDragEnter(
        [in, unique, annotation("__in_opt")] IShellItem *psiOver,
        [in, annotation("__in")] IShellItemArray *psiaData,
        [in, annotation("__in")] BOOL fOutsideSource,
        [in, annotation("__in")] DWORD grfKeyState,
        [in, out, annotation("__inout")] DWORD *pdwEffect);

    HRESULT OnDragOver(
        [in, unique, annotation("__in_opt")] IShellItem *psiOver,
        [in, annotation("__in")] IShellItemArray *psiaData,
        [in, annotation("__in")] DWORD grfKeyState,
        [in, out, annotation("__inout")] DWORD *pdwEffect);

    HRESULT OnDragPosition(
        [in, unique, annotation("__in_opt")] IShellItem *psiOver,
        [in, annotation("__in")] IShellItemArray *psiaData,
        [in, annotation("__in")] int iNewPosition,
        [in, annotation("__in")] int iOldPosition);

    HRESULT OnDrop(
        [in, unique, annotation("__in_opt")] IShellItem *psiOver,
        [in, annotation("__in")] IShellItemArray *psiaData,
        [in, annotation("__in")] int iPosition,
        [in, annotation("__in")] DWORD grfKeyState,
        [in, out, annotation("__inout")] DWORD *pdwEffect);

    HRESULT OnDropPosition(
        [in, unique, annotation("__in_opt")] IShellItem *psiOver,
        [in, annotation("__in")] IShellItemArray *psiaData,
        [in, annotation("__in")] int iNewPosition,
        [in, annotation("__in")] int iOldPosition);

    HRESULT OnDragLeave([in, unique, annotation("__in_opt")] IShellItem *psiOver);
};

[
    object,
    uuid(71f312de-43ed-4190-8477-e9536b82350b),
    local
]
interface INameSpaceTreeAccessible : IUnknown
{
    HRESULT OnGetDefaultAccessibilityAction(
        [in, annotation("__in")] IShellItem *psi,
        [out, annotation("__deref_out")] BSTR *pbstrDefaultAction);

    HRESULT OnDoDefaultAccessibilityAction([in, annotation("__in")] IShellItem *psi);

    HRESULT OnGetAccessibilityRole(
        [in, annotation("__in")] IShellItem *psi,
        [out, annotation("__out")] VARIANT *pvarRole);
}

[
    object,
    uuid(2D3BA758-33EE-42d5-BB7B-5F3431D86C78),
    local
]
interface INameSpaceTreeControlCustomDraw : IUnknown
{
    typedef struct NSTCCUSTOMDRAW
    {
        IShellItem *psi;
        UINT uItemState; // CDIS_xxx values
        NSTCITEMSTATE nstcis;
        LPCWSTR pszText;
        int iImage;
        HIMAGELIST himl;
        int iLevel;
        int iIndent;
    } NSTCCUSTOMDRAW;

    HRESULT PrePaint(
        [in, annotation("__in")] HDC hdc,
        [in, annotation("__in")] RECT *prc,
        [out, annotation("__out")] LRESULT *plres);

    HRESULT PostPaint(
        [in, annotation("__in")] HDC hdc,
        [in, annotation("__in")] RECT *prc);

    HRESULT ItemPrePaint(
        [in, annotation("__in")] HDC hdc,
        [in, annotation("__in")] RECT *prc,
        [in, annotation("__in")] NSTCCUSTOMDRAW *pnstccdItem,
        [in, out, annotation("__inout")] COLORREF *pclrText,
        [in, out, annotation("__inout")] COLORREF *pclrTextBk,
        [out, annotation("__out")] LRESULT *plres);

    HRESULT ItemPostPaint(
        [in, annotation("__in")] HDC hdc,
        [in, annotation("__in")] RECT *prc,
        [in, annotation("__in")] NSTCCUSTOMDRAW *pnstccdItem);
}

//cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
[
    object,
    uuid(e9701183-e6b3-4ff2-8568-813615fec7be),
    local
]
interface INameSpaceTreeControlFolderCapabilities : IUnknown
{
    typedef [v1_enum] enum NSTCFOLDERCAPABILITIES
    {
        NSTCFC_NONE                    = 0x00000000,
        NSTCFC_PINNEDITEMFILTERING     = 0x00000001, // Supports filtering based on PKEY_IsPinnedToNameSpaceTree
        NSTCFC_DELAY_REGISTER_NOTIFY   = 0x00000002, // Delays registration for change notifications until expanded in navigation pane
    } NSTCFOLDERCAPABILITIES;
    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(NSTCFOLDERCAPABILITIES)")

    HRESULT GetFolderCapabilities([in, annotation("__in")] NSTCFOLDERCAPABILITIES nfcMask, [out, annotation("__out")] NSTCFOLDERCAPABILITIES *pnfcValue);
}

cpp_quote("#endif  // NTDDI_VISTA")

// New for Vista, but used by downlevel code
//cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
// IPreviewHandler::DoPreview error codes
cpp_quote("#define E_PREVIEWHANDLER_DRM_FAIL _HRESULT_TYPEDEF_(0x86420001L)") // blocked by digital rights management
cpp_quote("#define E_PREVIEWHANDLER_NOAUTH   _HRESULT_TYPEDEF_(0x86420002L)") // blocked by file permissions
cpp_quote("#define E_PREVIEWHANDLER_NOTFOUND _HRESULT_TYPEDEF_(0x86420003L)") // item was not found
cpp_quote("#define E_PREVIEWHANDLER_CORRUPT  _HRESULT_TYPEDEF_(0x86420004L)") // item was corrupt

[
    object,
    uuid(8895b1c6-b41f-4c1c-a562-0d564250836f),
]
interface IPreviewHandler : IUnknown
{
    HRESULT SetWindow(
        [in] HWND hwnd,
        [in] const RECT *prc);

    HRESULT SetRect([in] const RECT *prc);

    HRESULT DoPreview();

    HRESULT Unload();

    HRESULT SetFocus();

    HRESULT QueryFocus([out] HWND* phwnd);

    HRESULT TranslateAccelerator([in] MSG* pmsg);
}

[
    object,
    uuid(fec87aaf-35f9-447a-adb7-20234491401a),
    pointer_default(unique)
]
interface IPreviewHandlerFrame: IUnknown
{
    typedef struct
    {
        HACCEL haccel;
        UINT   cAccelEntries;
    } PREVIEWHANDLERFRAMEINFO;

    HRESULT GetWindowContext([out] PREVIEWHANDLERFRAMEINFO* pinfo);

    HRESULT TranslateAccelerator([in] MSG* pmsg);
};
//cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")

//
// for show/hide deskbands
//
[
    object,
    uuid(6D67E846-5B9C-4db8-9CBC-DDE12F4254F1),
    pointer_default(unique)
]
interface ITrayDeskBand : IUnknown
{
    HRESULT ShowDeskBand([in] REFCLSID clsid);

    HRESULT HideDeskBand([in] REFCLSID clsid);

    HRESULT IsDeskBandShown([in] REFCLSID clsid);

    HRESULT DeskBandRegistrationChanged();
}

[
    uuid(B9075C7C-D48E-403f-AB99-D6C77A1084AC),
    object,
    pointer_default(unique)
]
interface IBandHost : IUnknown
{
    HRESULT CreateBand(
        [in] REFCLSID rclsidBand,
        [in] BOOL fAvailable,
        [in] BOOL fVisible,
        [in] REFIID riid,
        [out, iid_is(riid)]void **ppv);

    HRESULT SetBandAvailability(
        [in] REFCLSID rclsidBand,
        [in] BOOL fAvailable);

    HRESULT DestroyBand([in] REFCLSID rclsidBand);
}

cpp_quote("#define SID_SBandHost IID_IBandHost")

typedef GUID EXPLORERPANE; // identifies panes

// these typedefs are used only for the MIDL pass, everyone else gets the cpp_quote stuff
cpp_quote("#if 0")
    typedef EXPLORERPANE *REFEXPLORERPANE;
cpp_quote("#endif // 0")

cpp_quote("#ifdef __cplusplus")
cpp_quote("#define REFEXPLORERPANE const EXPLORERPANE &")
cpp_quote("#else // !__cplusplus")
cpp_quote("#define REFEXPLORERPANE const EXPLORERPANE * __MIDL_CONST")
cpp_quote("#endif // __cplusplus")

[
    object,
    uuid(e07010ec-bc17-44c0-97b0-46c7c95b9edc),
    local,
    pointer_default(unique)
]
interface IExplorerPaneVisibility : IUnknown
{
    [v1_enum] enum _EXPLORERPANESTATE
    {
        // ordinals
        EPS_DONTCARE     = 0x0000,  // don't impact the pane at all
        EPS_DEFAULT_ON   = 0x0001,  // set its default state to "on", however user-modified persisted state is respected.
        EPS_DEFAULT_OFF  = 0x0002,  //  "   "   "  "off".
        EPS_STATEMASK    = 0xFFFF,

        // flags
        // not all ExplorerPanes will necessarily respect these flags
        EPS_INITIALSTATE      = 0x00010000,  // ignore persisted state from the user, but user can still modify the state.
        EPS_FORCE             = 0x00020000,  // user can't modify the state (i.e. hide affordances for show/hide).  implies EPS_INITIALSTATE.
    };
    typedef DWORD EXPLORERPANESTATE;

    // each pane has its own semantic, for example the NavPane is opt-out, so EPS_DONTCARE means you'll typically have the
    // NavPane displayed, clients who want it to never show will pass EPS_DEFAULT_OFF | EPS_FORCE.
    // QueryPane is opt-in, so it will only show for clients who pass EPS_DEFAULT_ON.  however its default persisted state
    // is "off" so if you want to force it on you have to pass EPS_DEFAULT_ON | EPS_INITIALSTATE.

    // IExplorerPaneVisibility client can provide default states by returning EXPLORERPANESTATE here,
    // failure of GetPaneState corresponds to EPS_DONTCARE.
    HRESULT GetPaneState([in, annotation("__in")] REFEXPLORERPANE ep, [out, annotation("__out")] EXPLORERPANESTATE *peps);
}
cpp_quote("#define SID_ExplorerPaneVisibility IID_IExplorerPaneVisibility")

// controls the behavior of the SHCreateDefaultContextMenu()

[
    object,
    uuid(3409E930-5A39-11d1-83FA-00A0C90DC849),
    pointer_default(unique),
    local
]
interface IContextMenuCB : IUnknown
{
    // uMsg is one of DFM_XXX values
    HRESULT CallBack(
        [in, unique, annotation("__in_opt")] IShellFolder *psf,
        [in, unique, annotation("__in_opt")] HWND hwndOwner,
        [in, unique, annotation("__in_opt")] IDataObject *pdtobj,
        [in, annotation("__in")] UINT uMsg,
        [in, annotation("__in")] WPARAM wParam,
        [in, annotation("__in")] LPARAM lParam);
}

cpp_quote("#endif  // NTDDI_VISTA")

[
    object,
    uuid(41ded17d-d6b3-4261-997d-88c60e4b1d58),
    local,
    pointer_default(unique)
]
interface IDefaultExtractIconInit : IUnknown
{
    // set IExtractIcon GIL_XXX flags
    HRESULT SetFlags([in, annotation("__in")] UINT uFlags);

    // set the registry key to load "DefaultIcon" value from
    HRESULT SetKey([in, annotation("__in")] HKEY hkey);

    // set the various forms of icons, if pszFile is NULL iIcon is SHSTOCKICONID (SIID_) value
    HRESULT SetNormalIcon(
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszFile,
        [in, annotation("__in")] int iIcon);

    HRESULT SetOpenIcon(
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszFile,
        [in, annotation("__in")] int iIcon);

    HRESULT SetShortcutIcon(
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszFile,
        [in, annotation("__in")] int iIcon);

    HRESULT SetDefaultIcon(
        [in, unique, string, annotation("__in_opt")] LPCWSTR pszFile,
        [in, annotation("__in")] int iIcon);
}

// "Default" IExtractIcon implementation useful for implementation of ::GetUIObjectOf(IID_IExtractIcon)
cpp_quote("STDAPI SHCreateDefaultExtractIcon(__in REFIID riid, __deref_out void **ppv);")

interface IEnumExplorerCommand;

[
    uuid(a08ce4d0-fa25-44ab-b57c-c7b1c323e0b9),
    pointer_default(unique)
]
interface IExplorerCommand : IUnknown
{
    [v1_enum] enum _EXPCMDSTATE
    {
        ECS_ENABLED     = 0x00,
        ECS_DISABLED    = 0x01,
        ECS_HIDDEN      = 0x02,
        ECS_CHECKBOX    = 0x04,
        ECS_CHECKED     = 0x08,
        ECS_RADIOCHECK  = 0x10,
    };
    typedef DWORD EXPCMDSTATE;

    [v1_enum] enum _EXPCMDFLAGS
    {
        ECF_DEFAULT =          0x00,
        ECF_HASSUBCOMMANDS =   0x01,
        ECF_HASSPLITBUTTON =   0x02,
        ECF_HIDELABEL =        0x04,
        ECF_ISSEPARATOR =      0x08,
        ECF_HASLUASHIELD =     0x10,
        ECF_SEPARATORBEFORE =  0x20,
        ECF_SEPARATORAFTER =   0x40,
        ECF_ISDROPDOWN =       0x80,
    };
    typedef DWORD EXPCMDFLAGS;

    HRESULT GetTitle(
        [in, unique] IShellItemArray *psiItemArray,
        [out, string] LPWSTR *ppszName);

    HRESULT GetIcon(
        [in, unique] IShellItemArray *psiItemArray,
        [out, string] LPWSTR *ppszIcon); // we support icon resource strings like: "shell32,-123"

    HRESULT GetToolTip(
        [in, unique] IShellItemArray *psiItemArray,
        [out, string] LPWSTR *ppszInfotip);

    HRESULT GetCanonicalName([out] GUID* pguidCommandName);

    HRESULT GetState(
        [in] IShellItemArray *psiItemArray,
        [in] BOOL fOkToBeSlow,
        [out] EXPCMDSTATE *pCmdState);

    HRESULT Invoke(
        [in] IShellItemArray *psiItemArray,
        [in, unique] IBindCtx *pbc);

    HRESULT GetFlags([out] EXPCMDFLAGS *pFlags);

    HRESULT EnumSubCommands([out] IEnumExplorerCommand **ppEnum);
};

[
    uuid(bddacb60-7657-47ae-8445-d23e1acf82ae),
    object,
    pointer_default(unique)
]
interface IExplorerCommandState : IUnknown
{
    HRESULT GetState([in] IShellItemArray *psiItemArray, [in] BOOL fOkToBeSlow, [out] EXPCMDSTATE *pCmdState);
}

[
    object,
    uuid(85075acf-231f-40ea-9610-d26b7b58f638),
    pointer_default(unique)
]
interface IInitializeCommand : IUnknown
{
    HRESULT Initialize([in, string] LPCWSTR pszCommandName, [in] IPropertyBag *ppb);
}

[
    uuid(a88826f8-186f-4987-aade-ea0cef8fbfe8),
    object,
    pointer_default(unique)
]
interface IEnumExplorerCommand : IUnknown
{
    [local]
    HRESULT Next(
        [in, annotation("__in")] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched), annotation("__out_ecount_part(celt, *pceltFetched)")] IExplorerCommand** pUICommand,
        [out, annotation("__out_opt __deref_out_range(0, celt)")] ULONG *pceltFetched);

    [call_as(Next)]
    HRESULT RemoteNext(
        [in] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched)] IExplorerCommand** pUICommand,
        [out] ULONG *pceltFetched);

    HRESULT Skip([in] ULONG celt);

    HRESULT Reset();

    HRESULT Clone([out] IEnumExplorerCommand **ppenum);
};

[
    uuid(64961751-0835-43c0-8ffe-d57686530e64),
    pointer_default(unique)
]
interface IExplorerCommandProvider : IUnknown
{
    // IEnumExplorerCommand
    HRESULT GetCommands(
        [in] IUnknown *punkSite,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);

    // IExplorerCommand
    HRESULT GetCommand(
        [in] REFGUID rguidCommandId,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);
};



typedef HANDLE HTHEME;


[
    object,
    uuid(6e0f9881-42a8-4f2a-97f8-8af4e026d92d),
    pointer_default(unique)
]
interface IInitializeNetworkFolder : IUnknown
{
    HRESULT Initialize(
        [in, unique] PCIDLIST_ABSOLUTE pidl,
        [in, unique] PCIDLIST_ABSOLUTE pidlTarget,
        [in] UINT uDisplayType,                     // RESOURCEDISPLAYTYPE_ values
        [in, unique, string] LPCWSTR pszResName,    // server or server share name
        [in, unique, string] LPCWSTR pszProvider);  // network provider name
};

typedef [v1_enum] enum CPVIEW
{
    CPVIEW_CLASSIC   = 0,
    CPVIEW_ALLITEMS  = CPVIEW_CLASSIC,
    CPVIEW_CATEGORY  = 1,
    CPVIEW_HOME      = CPVIEW_CATEGORY,
} CPVIEW;

[
    object,
    uuid(D11AD862-66DE-4DF4-BF6C-1F5621996AF1),
]
interface IOpenControlPanel : IUnknown
{
    HRESULT Open(
        [in, unique, string] LPCWSTR pszName,
        [in, unique, string] LPCWSTR pszPage,
        [in, unique] IUnknown *punkSite);

    HRESULT GetPath(
        [in, unique, string] LPCWSTR pszName,
        [out, string, size_is(cchPath)] LPWSTR pszPath,
        [in] UINT cchPath);

    HRESULT GetCurrentView([out] CPVIEW *pView);
};

[
    object,
    uuid(0DF60D92-6818-46d6-B358-D66170DDE466),
    pointer_default(unique)
]
interface IComputerInfoChangeNotify : IUnknown
{
    HRESULT ComputerInfoChanged();
};

// IShellFolder IBindCtx parameter: "File System Bind Data".
//
// The IUnknown for this is accessed through IBindCtx::RegisterObjectParam/GetObjectParam.
//
// Use this to provide the data needed to create IDLists through IShellFolder::ParseDisplayName(). 
//
// This data applies to the last element of the name that is parsed (c:\foo\bar.txt, 
// data applies to bar.txt).
//
// This makes creating these IDLists much faster than supplying the name only.
// This is sometimes referred to as "simple parsing".

cpp_quote("#define STR_FILE_SYS_BIND_DATA      L\"File System Bind Data\"")

[
    object,
    uuid(01E18D10-4D8B-11d2-855D-006008059367),
    pointer_default(unique),
    local
]
interface IFileSystemBindData : IUnknown
{
    HRESULT SetFindData([in] const WIN32_FIND_DATAW *pfd);
    HRESULT GetFindData([out] WIN32_FIND_DATAW *pfd);
};

[
    object,
    uuid(3acf075f-71db-4afa-81f0-3fc4fdf2a5b8),
    pointer_default(unique),
    local
]
interface IFileSystemBindData2 : IFileSystemBindData
{
    HRESULT SetFileID([in] LARGE_INTEGER liFileID);
    HRESULT GetFileID([out] LARGE_INTEGER *pliFileID);
    HRESULT SetJunctionCLSID([in] REFCLSID clsid);
    HRESULT GetJunctionCLSID([out] CLSID *pclsid);
};

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN7)")

// Custom Destination List
[
    uuid(6332debf-87b5-4670-90c0-5e57b408a49e),
    object,
    pointer_default(unique),
]
interface ICustomDestinationList : IUnknown
{
    typedef [v1_enum] enum KNOWNDESTCATEGORY
    {
        KDC_FREQUENT = 1,
        KDC_RECENT,
    } KNOWNDESTCATEGORY;

    HRESULT SetAppID([in, string] LPCWSTR pszAppID);
    // Retrieve IObjectArray of IShellItems or IShellLinks that represent removed destinations
    HRESULT BeginList(
        [out] UINT *pcMinSlots,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);
    HRESULT AppendCategory(
        [in, string] LPCWSTR pszCategory, 
        [in] IObjectArray *poa);
    HRESULT AppendKnownCategory([in] KNOWNDESTCATEGORY category);
    HRESULT AddUserTasks([in] IObjectArray *poa);
    HRESULT CommitList();
    // Retrieve IObjectCollection of IShellItems
    HRESULT GetRemovedDestinations(
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv);
    HRESULT DeleteList([in, unique, string] LPCWSTR pszAppID);
    HRESULT AbortList();
};

// Used to remove items from the automatic destination lists created when apps or the system call SHAddToRecentDocs to report usage of a document.
[
    uuid(12337d35-94c6-48a0-bce7-6a9c69d4d600),
    object,
    pointer_default(unique),
]
interface IApplicationDestinations : IUnknown
{
    // Set the App User Model ID for the application removing destinations from its list.  If an AppID is not provided 
    // via this method, the system will use a heuristically determined ID.  This method must be called before
    // RemoveDestination or RemoveAllDestinations.
    HRESULT SetAppID([in] LPCWSTR pszAppID);
    // Remove an IShellItem or an IShellLink from the automatic destination list
    HRESULT RemoveDestination([in] IUnknown *punk);
    // Clear the frequent and recent destination lists for this application.
    HRESULT RemoveAllDestinations();
};

// Allows an application to retrieve the most recent and frequent documents opened in that app, as reported via SHAddToRecentDocs
[
    uuid(3c594f9f-9f30-47a1-979a-c9e83d3d0a06),
    object,
    pointer_default(unique),
]
interface IApplicationDocumentLists : IUnknown
{
    typedef [v1_enum] enum APPDOCLISTTYPE
    {
        ADLT_RECENT = 0,   // The recently used documents list
        ADLT_FREQUENT,     // The frequently used documents list
    } APPDOCLISTTYPE;

    // Set the App User Model ID for the application retrieving this list.  If an AppID is not provided via this method,
    // the system will use a heuristically determined ID.  This method must be called before GetList.
    HRESULT SetAppID([in] LPCWSTR pszAppID);
    // Retrieve an IEnumObjects or IObjectArray for IShellItems and/or IShellLinks. 
    // Items may appear in both the frequent and recent lists. 
    HRESULT GetList([in] APPDOCLISTTYPE listtype, [in] UINT cItemsDesired, [in] REFIID riid, [out, iid_is(riid)] void **ppv);
};

// Provides access to the App User Model ID on objects supporting this value
[
    uuid(36db0196-9665-46d1-9ba7-d3709eecf9ed),
    object,
    pointer_default(unique)
]
interface IObjectWithAppUserModelID : IUnknown
{
    HRESULT SetAppID([in, string] LPCWSTR pszAppID);
    HRESULT GetAppID([out, string] LPWSTR *ppszAppID);
};

// Provides access to the ProgID associated with an object
[
    uuid(71e806fb-8dee-46fc-bf8c-7748a8a1ae13),
    object,
    pointer_default(unique)
]
interface IObjectWithProgID : IUnknown
{
    HRESULT SetProgID([in, string] LPCWSTR pszProgID);
    HRESULT GetProgID([out, string] LPWSTR *ppszProgID);
};

[
    uuid(6589b6d2-5f8d-4b9e-b7e0-23cdd9717d8c),
    local,
    pointer_default(unique)
]
interface IUpdateIDList : IUnknown
{
    // Implemented by an IShellFolder implementation, this method updates the provided child IDList based on the
    // parameters specified by the provided IBindCtx.  If pbc is NULL, or does not contain any parameters that
    // apply to the current Shell Folder, pidlIn should simply be cloned into ppidlOut.
    HRESULT Update(
        [in, unique, annotation("__in_opt")] IBindCtx *pbc,
        [in, annotation("__in")] PCUITEMID_CHILD pidlIn,
        [out, annotation("__deref_out")] PITEMID_CHILD *ppidlOut);
};

// Sets the User Model AppID for the current process, enabling Windows to retrieve this ID
cpp_quote("SHSTDAPI SetCurrentProcessExplicitAppUserModelID(__in PCWSTR AppID);") 

// Retrieves the User Model AppID that has been explicitly set for the current process via 
// SetCurrentProcessExplicitAppUserModelID
cpp_quote("SHSTDAPI GetCurrentProcessExplicitAppUserModelID(__deref_out PWSTR *AppID);")

cpp_quote("#endif // NTDDI_WIN7")

[
    object, 
    uuid(c1646bc4-f298-4f91-a204-eb2dd1709d1a),
]
interface IDesktopGadget : IUnknown
{
    HRESULT RunGadget([in] LPCWSTR gadgetPath);
};

cpp_quote("#define HOMEGROUP_SECURITY_GROUP L\"HomeUsers\"")

// IHomeGroup
[
    uuid(7a3bd1d9-35a9-4fb3-a467-f48cac35e2d0),
    object,
    local
]
interface IHomeGroup : IUnknown
{
    typedef [v1_enum] enum HOMEGROUPSHARINGCHOICES
    {
        HGSC_NONE             = 0x00000000,
        HGSC_MUSICLIBRARY     = 0x00000001,
        HGSC_PICTURESLIBRARY  = 0x00000002,
        HGSC_VIDEOSLIBRARY    = 0x00000004,
        HGSC_DOCUMENTSLIBRARY = 0x00000008,
        HGSC_PRINTERS         = 0x00000010,
    } HOMEGROUPSHARINGCHOICES;
    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(HOMEGROUPSHARINGCHOICES)")

    HRESULT IsMember([out] BOOL *member);
    HRESULT ShowSharingWizard([in] HWND owner, [out] HOMEGROUPSHARINGCHOICES *sharingchoices);
};

[
    helpstring("Initialize With IPropertyStore"),
    uuid(C3E12EB5-7D8D-44f8-B6DD-0E77B34D6DE4),
    object,
    pointer_default(unique)
]
interface IInitializeWithPropertyStore : IUnknown
{
    HRESULT Initialize([in] IPropertyStore *pps);
};

[
    helpstring("OpenSearch Data Source API"),
    uuid(F0EE7333-E6FC-479b-9F25-A860C234A38E),
    object,
    pointer_default(unique),
]
interface IOpenSearchSource : IUnknown
{
    HRESULT GetResults(
                [in] HWND hwnd,
                [in] LPCWSTR pszQuery,
                [in] DWORD dwStartIndex,
                [in] DWORD dwCount,
                [in] REFIID riid,
                [out, iid_is(riid)] void **ppv);  // return IStream

};

// Library API
[
    helpstring("Shell Library API"),
    uuid(11a66efa-382e-451a-9234-1e0e12ef3085),
    object,
    pointer_default(unique),
]
interface IShellLibrary : IUnknown
{
    typedef [v1_enum] enum LIBRARYFOLDERFILTER
    {
        LFF_FORCEFILESYSTEM       = 1,  // Return only file system items.
        LFF_STORAGEITEMS          = 2,  // Return any items that can be bound to an IStorage. (default)
        LFF_ALLITEMS              = 3,  // Return all items.
    } LIBRARYFOLDERFILTER;

    typedef [v1_enum] enum LIBRARYOPTIONFLAGS
    {
        LOF_DEFAULT          = 0x00000000,
        LOF_PINNEDTONAVPANE  = 0x00000001,  // Specifies that this library is pinned to the navigation pane.
        LOF_MASK_ALL         = 0x00000001,
    } LIBRARYOPTIONFLAGS;

    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(LIBRARYOPTIONFLAGS)")

    typedef [v1_enum] enum DEFAULTSAVEFOLDERTYPE
    {
        DSFT_DETECT = 1,  // Specifies the save folder for the current user depending on whether or not they are the owner of the library
        DSFT_PRIVATE,     // Specifies the private save folder for the owner of the library
        DSFT_PUBLIC,      // Specifies the public save folder for non-owners of the library
    } DEFAULTSAVEFOLDERTYPE;

    typedef [v1_enum] enum LIBRARYSAVEFLAGS
    {
        LSF_FAILIFTHERE         = 0x00000000,   // if a library with the same name exists fail to save
        LSF_OVERRIDEEXISTING    = 0x00000001,   // will override existing library with the same name if there or create a new one if not
        LSF_MAKEUNIQUENAME      = 0x00000002,   // if a library with the same name exists create a unique name by adding a number in parenthesis
    } LIBRARYSAVEFLAGS;

    cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(LIBRARYSAVEFLAGS)")
    
    HRESULT LoadLibraryFromItem([in] IShellItem *psiLibrary, [in] DWORD grfMode);
    HRESULT LoadLibraryFromKnownFolder([in] REFKNOWNFOLDERID kfidLibrary, [in] DWORD grfMode);

    HRESULT AddFolder([in] IShellItem *psiLocation);
    HRESULT RemoveFolder([in] IShellItem *psiLocation);

    // may return S_FALSE if some folders were omitted due to errors during enumeration
    HRESULT GetFolders(
        [in] LIBRARYFOLDERFILTER lff,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv); // returns IShellItemArray

    // returns S_FALSE if no resolution was necessary; resolved folder will not be saved until Save[InKnownFolder] or Commit is called
    HRESULT ResolveFolder(
        [in] IShellItem *psiFolderToResolve,
        [in] DWORD dwTimeout,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv); // returns IShellItem

    HRESULT GetDefaultSaveFolder(
        [in] DEFAULTSAVEFOLDERTYPE dsft,
        [in] REFIID riid,
        [out, iid_is(riid)] void **ppv); // returns IShellItem

    HRESULT SetDefaultSaveFolder([in] DEFAULTSAVEFOLDERTYPE dsft, [in] IShellItem *psi);

    HRESULT GetOptions([out] LIBRARYOPTIONFLAGS *plofOptions);
    HRESULT SetOptions([in] LIBRARYOPTIONFLAGS lofMask, [in] LIBRARYOPTIONFLAGS lofOptions);

    HRESULT GetFolderType([out] FOLDERTYPEID *pftid);
    HRESULT SetFolderType([in] REFFOLDERTYPEID ftid);

    HRESULT GetIcon([out, string] LPWSTR *ppszIcon);
    HRESULT SetIcon([in, string] LPCWSTR pszIcon);

    HRESULT Commit();

    HRESULT Save(
        [in] IShellItem *psiFolderToSaveIn, 
        [in, string] LPCWSTR pszLibraryName,    // name without an extension
        [in] LIBRARYSAVEFLAGS lsf, 
        [out] IShellItem **ppsiSavedTo);

    HRESULT SaveInKnownFolder(
        [in] REFKNOWNFOLDERID kfidToSaveIn, 
        [in, string] LPCWSTR pszLibraryName,    // name without an extension
        [in] LIBRARYSAVEFLAGS lsf, 
        [out] IShellItem **ppsiSavedTo);
};

//
//  NOTE - this typelib is never registered anywhere
//  objects that want their typelibs to be registered
//  in shell32 should add their coclass to shldisp.idl
//
// Microsoft Shell Objects
[
    uuid(50a7e9b1-70ef-11d1-b75a-00a0c90564fe), // LIBID_ShellObjects
    lcid(0x0000),
    version(1.0)
]
library ShellObjects
{
    // CLSID_ShellDesktop
    [ uuid(00021400-0000-0000-C000-000000000046) ] coclass ShellDesktop { interface IShellFolder2; }

    // CLSID_ShellFSFolder
    [ uuid(F3364BA0-65B9-11CE-A9BA-00AA004AE837) ] coclass ShellFSFolder { interface IShellFolder2; }

    // CLSID_NetworkPlaces
    [ uuid(208D2C60-3AEA-1069-A2D7-08002B30309D) ] coclass NetworkPlaces { interface IShellFolder2; }

    // CLSID_ShellLink
    [ uuid(00021401-0000-0000-C000-000000000046) ] coclass ShellLink { interface IShellLinkW; }

    // CLSID_QueryCancelAutoPlay
    [ uuid(331F1768-05A9-4ddd-B86E-DAE34DDC998A) ] coclass QueryCancelAutoPlay { interface IQueryCancelAutoPlay; }

    // CLSID_DriveSizeCategorizer
    [ uuid(94357B53-CA29-4b78-83AE-E8FE7409134F) ] coclass DriveSizeCategorizer { interface ICategorizer; }

    // CLSID_DriveTypeCategorizer
    [ uuid(B0A8F3CF-4333-4bab-8873-1CCB1CADA48B) ] coclass DriveTypeCategorizer { interface ICategorizer; }

    // CLSID_FreeSpaceCategorizer
    [ uuid(B5607793-24AC-44c7-82E2-831726AA6CB7) ] coclass FreeSpaceCategorizer { interface ICategorizer; }

    // CLSID_TimeCategorizer
    [ uuid(3bb4118f-ddfd-4d30-a348-9fb5d6bf1afe) ] coclass TimeCategorizer { interface ICategorizer; }

    // CLSID_SizeCategorizer
    [ uuid(55d7b852-f6d1-42f2-aa75-8728a1b2d264) ] coclass SizeCategorizer { interface ICategorizer; }

    // CLSID_AlphabeticalCategorizer
    [ uuid(3c2654c6-7372-4f6b-b310-55d6128f49d2) ] coclass AlphabeticalCategorizer { interface ICategorizer; }

    // CLSID_MergedCategorizer
    [ uuid(8e827c11-33e7-4bc1-b242-8cd9a1c2b304) ] coclass MergedCategorizer { interface ICategorizer; }

    // CLSID_ImageProperties
    [ uuid(7ab770c7-0e23-4d7a-8aa2-19bfad479829) ] coclass ImageProperties { interface IPersistFile; }

    // CLSID_PropertiesUI
    [ uuid(d912f8cf-0396-4915-884e-fb425d32943b) ] coclass PropertiesUI { interface IPropertyUI; }

    // CLSID_UserNotification
    [ uuid(0010890e-8789-413c-adbc-48f5b511b3af) ] coclass UserNotification { interface IUserNotification; }

    // CLSID_CDBurn
    [ uuid(fbeb8a05-beee-4442-804e-409d6c4515e9) ] coclass CDBurn { interface ICDBurn; }

    // CLSID_TaskbarList
    [ uuid(56FDF344-FD6D-11d0-958A-006097C9A090) ] coclass TaskbarList { interface ITaskbarList4; }

    // CLSID_StartMenuPin
    [ uuid(a2a9545d-a0c2-42b4-9708-a0b2badd77c8) ] coclass StartMenuPin { interface IStartMenuPinnedList; }

    // For supporting HTML wizard extensions we provide this object, it implements the IWizardExtenion
    // and allows the site to specific via an IPropertyBag an URL which should be displayed.  The property
    // bag is requested from the SID_WebWizardHost, and it used inturn to return parameter information
    // back to the site (eg. any information that the displayed HTML would like to communicate).

    // CLSID_WebWizardHost
    [ uuid(c827f149-55c1-4d28-935e-57e47caed973) ] coclass WebWizardHost { interface IWebWizardExtension; }

    // CLSID_PublishDropTarget
    [ uuid(CC6EEFFB-43F6-46c5-9619-51D571967F7D) ] coclass PublishDropTarget { interface IDropTarget; }

    // CLSID_PublishingWizard
    [ uuid(6b33163c-76a5-4b6c-bf21-45de9cd503a1) ] coclass PublishingWizard { interface IPublishingWizard; }
    cpp_quote("#define SID_PublishingWizard CLSID_PublishingWizard")

    // CLSID_InternetPrintOrdering
    [ uuid(add36aa8-751a-4579-a266-d66f5202ccbb) ] coclass InternetPrintOrdering { interface IDropTarget; }

    // CLSID_FolderViewHost
    [ uuid(20b1cb23-6968-4eb9-b7d4-a66d00d07cee) ] coclass FolderViewHost { interface IFolderViewHost; }

    // CLSID_ExplorerBrowser
    [ uuid(71f96385-ddd6-48d3-a0c1-ae06e8b055fb) ] coclass ExplorerBrowser { interface IExplorerBrowser; }

    // CLSID_ImageRecompress
    [ uuid(6e33091c-d2f8-4740-b55e-2e11d1477a2c) ] coclass ImageRecompress { interface IImageRecompress; }

    // CLSID_TrayBandSiteService
    [ uuid(F60AD0A0-E5E1-45cb-B51A-E15B9F8B2934) ] coclass TrayBandSiteService { interface IBandSite; }

    // CLSID_TrayDeskBand
    [ uuid(E6442437-6C68-4f52-94DD-2CFED267EFB9) ] coclass TrayDeskBand { interface ITrayDeskBand; }

    // CLSID_AttachmentServices
    [ uuid(4125dd96-e03a-4103-8f70-e0597d803b9c) ] coclass AttachmentServices { interface IAttachmentExecute; }

    // CLSID_DocPropShellExtension
    [ uuid(883373C3-BF89-11D1-BE35-080036B11A03) ] coclass DocPropShellExtension { interface IShellExtInit; }

    // CLSID_ShellItem
    [ uuid(9ac9fbe1-e0a2-4ad6-b4ee-e212013ea917) ] coclass ShellItem { interface IShellItem2; }

    // CLSID_NamespaceWalker
    [ uuid(72eb61e0-8672-4303-9175-f2e4c68b2e7c) ] coclass NamespaceWalker { interface INamespaceWalk; }

    // CLSID_FileOperation
    [ uuid(3ad05575-8857-4850-9277-11b85bdb8e09) ] coclass FileOperation { interface IFileOperation; }

    // CLSID_FileOpenDialog
    [ uuid(DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7) ] coclass FileOpenDialog { interface IFileOpenDialog; }

    // CLSID_FileSaveDialog
    [ uuid(C0B4E2F3-BA21-4773-8DBA-335EC946EB8B) ] coclass FileSaveDialog { interface IFileSaveDialog; }

    // CLSID_KnownFolderManager
    [ uuid(4df0c730-df9d-4ae3-9153-aa6b82e9795a) ] coclass KnownFolderManager { interface IKnownFolderManager; }

    // CLSID_FSCopyHandler
    [ uuid(D197380A-0A79-4dc8-A033-ED882C2FA14B) ] coclass FSCopyHandler { interface IUnknown; }

    // CLSID_SharingConfigurationManager
    [ uuid(49F371E1-8C5C-4d9c-9A3B-54A6827F513C) ] coclass SharingConfigurationManager { interface ISharingConfigurationManager; }

    // CLSID_PreviousVersions
    [ uuid(596AB062-B4D2-4215-9F74-E9109B0A8153) ] coclass PreviousVersions { interface IPreviousVersionsInfo; }

    // CLSID_NetworkConnections
    [ uuid(7007ACC7-3202-11D1-AAD2-00805FC1270E) ] coclass NetworkConnections { interface IShellFolder2; }

    // CLSID_NamespaceTreeControl
    [ uuid(AE054212-3535-4430-83ED-D501AA6680E6) ] coclass NamespaceTreeControl { interface INameSpaceTreeControl2; }

    // CLSID_IENamespaceTreeControl
    [ uuid(ACE52D03-E5CD-4b20-82FF-E71B11BEAE1D) ] coclass IENamespaceTreeControl { interface IUnknown; }

    // CLSID_ScheduledTasks
    [ uuid(D6277990-4C6A-11CF-8D87-00AA0060F5BF) ] coclass ScheduledTasks { interface IShellFolder2; }

    // CLSID_ApplicationAssociationRegistration
    [ uuid(591209c7-767b-42b2-9fba-44ee4615f2c7) ] coclass ApplicationAssociationRegistration { interface IApplicationAssociationRegistration; }

    // CLSID_ApplicationAssociationRegistrationUI
    [ uuid(1968106d-f3b5-44cf-890e-116fcb9ecef1) ] coclass ApplicationAssociationRegistrationUI { interface IApplicationAssociationRegistrationUI; }

    // CLSID_SearchFolderItemFactory
    [ uuid(14010e02-bbbd-41f0-88e3-eda371216584) ] coclass SearchFolderItemFactory { interface ISearchFolderItemFactory; }

    // CLSID_OpenControlPanel
    [ uuid(06622D85-6856-4460-8DE1-A81921B41C4B) ] coclass OpenControlPanel { interface IOpenControlPanel; }

    // CLSID_MailRecipient
    [ uuid(9E56BE60-C50F-11CF-9A2C-00A0C90A90CE) ] coclass MailRecipient { interface IDropTarget; }

    // CLSID_NetworkExplorerFolder
    [ uuid(F02C1A0D-BE21-4350-88B0-7367FC96EF3C) ] coclass NetworkExplorerFolder { interface IShellFolder2; }

    // CLSID_DestinationList
    [ uuid(77f10cf0-3db5-4966-b520-b7c54fd35ed6) ] coclass DestinationList { interface ICustomDestinationList; }

    // CLSID_ApplicationDestinations
    [ uuid(86c14003-4d6b-4ef3-a7b4-0506663b2e68) ] coclass ApplicationDestinations { interface IApplicationDestinations; }

    // CLSID_ApplicationDocumentLists
    [ uuid(86bec222-30f2-47e0-9f25-60d11cd75c28) ] coclass ApplicationDocumentLists { interface IApplicationDocumentLists; }

    // CLSID_HomeGroup
    [ uuid(DE77BA04-3C92-4d11-A1A5-42352A53E0E3) ] coclass HomeGroup { interface IHomeGroup; }

    // CLSID_ShellLibrary
    [ uuid(d9b3211d-e57f-4426-aaef-30a806add397) ] coclass ShellLibrary { interface IShellLibrary; }

    // CLSID_AppStartupLink
    [ uuid(273eb5e7-88b0-4843-bfef-e2c81d43aae5) ] coclass AppStartupLink { interface IShellLinkW; }

    // CLSID_EnumerableObjectCollection
    [ uuid(2d3468c1-36a7-43b6-ac24-d3f02fd9607a) ] coclass EnumerableObjectCollection { interface IEnumObjects; }

    // CLSID_DesktopGadget
    [ uuid(924ccc1b-6562-4c85-8657-d177925222b6) ] coclass DesktopGadget { interface IDesktopGadget; }
};

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
cpp_quote("SHSTDAPI SHGetTemporaryPropertyForItem(__in IShellItem *psi, __in REFPROPERTYKEY propkey, __out PROPVARIANT *ppropvar);")
cpp_quote("SHSTDAPI SHSetTemporaryPropertyForItem(__in IShellItem *psi, __in REFPROPERTYKEY propkey, __in REFPROPVARIANT propvar);")
cpp_quote("#endif  // NTDDI_VISTA")


// helper APIs to simplify initializing an instance of IShellLibrary and working with file system paths
cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN7)")
cpp_quote("#if (_WIN32_IE >= _WIN32_IE_IE70)")

typedef [v1_enum] enum LIBRARYMANAGEDIALOGOPTIONS
{
    LMD_DEFAULT                             = 0x00000000,
    LMD_ALLOWUNINDEXABLENETWORKLOCATIONS    = 0x00000001,   // The caller of SHShowManageLibraryUI does not want to show any warning dialogs about network locations that cannot be indexed
} LIBRARYMANAGEDIALOGOPTIONS;

cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(LIBRARYMANAGEDIALOGOPTIONS)")

cpp_quote("SHSTDAPI SHShowManageLibraryUI(__in IShellItem *psiLibrary, __in HWND hwndOwner, __in_opt LPCWSTR pszTitle, __in_opt LPCWSTR pszInstruction, __in LIBRARYMANAGEDIALOGOPTIONS lmdOptions);")
cpp_quote("SHSTDAPI SHResolveLibrary(__in IShellItem *psiLibrary);")
cpp_quote("#ifdef __cplusplus")
cpp_quote("")
cpp_quote("__inline HRESULT SHCreateLibrary(__in REFIID riid, __deref_out void **ppv)")
cpp_quote("{")
cpp_quote("    return CoCreateInstance(CLSID_ShellLibrary, NULL, CLSCTX_INPROC_SERVER, riid, ppv);")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHLoadLibraryFromItem(__in IShellItem *psiLibrary, __in DWORD grfMode, __in REFIID riid, __deref_out void **ppv)")
cpp_quote("{")
cpp_quote("    *ppv = NULL;")
cpp_quote("    IShellLibrary *plib;")
cpp_quote("    HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&plib));")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        hr = plib->LoadLibraryFromItem(psiLibrary, grfMode);")
cpp_quote("        if (SUCCEEDED(hr))")
cpp_quote("        {")
cpp_quote("            hr = plib->QueryInterface(riid, ppv);")
cpp_quote("        }")
cpp_quote("        plib->Release();")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHLoadLibraryFromKnownFolder(__in REFKNOWNFOLDERID kfidLibrary, __in DWORD grfMode, __in REFIID riid, __deref_out void **ppv)")
cpp_quote("{")
cpp_quote("    *ppv = NULL;")
cpp_quote("    IShellLibrary *plib;")
cpp_quote("    HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&plib));")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        hr = plib->LoadLibraryFromKnownFolder(kfidLibrary, grfMode);")
cpp_quote("        if (SUCCEEDED(hr))")
cpp_quote("        {")
cpp_quote("            hr = plib->QueryInterface(riid, ppv);")
cpp_quote("        }")
cpp_quote("        plib->Release();")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHLoadLibraryFromParsingName(__in PCWSTR pszParsingName, __in DWORD grfMode, __in REFIID riid, __deref_out void **ppv)")
cpp_quote("{")
cpp_quote("    *ppv = NULL;")
cpp_quote("    IShellItem *psiLibrary;")
cpp_quote("    HRESULT hr = SHCreateItemFromParsingName(pszParsingName, NULL, IID_PPV_ARGS(&psiLibrary));")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        hr = SHLoadLibraryFromItem(psiLibrary, grfMode, riid, ppv);")
cpp_quote("        psiLibrary->Release();")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHAddFolderPathToLibrary(__in IShellLibrary *plib, __in PCWSTR pszFolderPath)")
cpp_quote("{")
cpp_quote("    IShellItem *psiFolder;")
cpp_quote("    HRESULT hr = SHCreateItemFromParsingName(pszFolderPath, NULL, IID_PPV_ARGS(&psiFolder));")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        hr = plib->AddFolder(psiFolder);")
cpp_quote("        psiFolder->Release();")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHRemoveFolderPathFromLibrary(__in IShellLibrary *plib, __in PCWSTR pszFolderPath)")
cpp_quote("{")
cpp_quote("    PIDLIST_ABSOLUTE pidlFolder = SHSimpleIDListFromPath(pszFolderPath);")
cpp_quote("    HRESULT hr = pidlFolder ? S_OK : E_INVALIDARG;")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        IShellItem *psiFolder;")
cpp_quote("        hr = SHCreateItemFromIDList(pidlFolder, IID_PPV_ARGS(&psiFolder));")
cpp_quote("        if (SUCCEEDED(hr))")
cpp_quote("        {")
cpp_quote("            hr = plib->RemoveFolder(psiFolder);")
cpp_quote("            psiFolder->Release();")
cpp_quote("        }")
cpp_quote("        CoTaskMemFree(pidlFolder);")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHResolveFolderPathInLibrary(__in IShellLibrary *plib, __in PCWSTR pszFolderPath, __in DWORD dwTimeout, __deref_out PWSTR *ppszResolvedPath)")
cpp_quote("{")
cpp_quote("    *ppszResolvedPath = NULL;")
cpp_quote("    PIDLIST_ABSOLUTE pidlFolder = SHSimpleIDListFromPath(pszFolderPath);")
cpp_quote("    HRESULT hr = pidlFolder ? S_OK : E_INVALIDARG;")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        IShellItem *psiFolder;")
cpp_quote("        hr = SHCreateItemFromIDList(pidlFolder, IID_PPV_ARGS(&psiFolder));")
cpp_quote("        if (SUCCEEDED(hr))")
cpp_quote("        {")
cpp_quote("            IShellItem *psiResolved;")
cpp_quote("            hr = plib->ResolveFolder(psiFolder, dwTimeout, IID_PPV_ARGS(&psiResolved));")
cpp_quote("            if (SUCCEEDED(hr))")
cpp_quote("            {")
cpp_quote("                hr = psiResolved->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, ppszResolvedPath);")
cpp_quote("                psiResolved->Release();")
cpp_quote("            }")
cpp_quote("            psiFolder->Release();")
cpp_quote("        }")
cpp_quote("        CoTaskMemFree(pidlFolder);")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("")
cpp_quote("__inline HRESULT SHSaveLibraryInFolderPath(__in IShellLibrary *plib, __in PCWSTR pszFolderPath, __in PCWSTR pszLibraryName, __in LIBRARYSAVEFLAGS lsf, __deref_opt_out PWSTR *ppszSavedToPath)")
cpp_quote("{")
cpp_quote("    if (ppszSavedToPath)")
cpp_quote("    {")
cpp_quote("        *ppszSavedToPath = NULL;")
cpp_quote("    }")
cpp_quote("")
cpp_quote("    IShellItem *psiFolder;")
cpp_quote("    HRESULT hr = SHCreateItemFromParsingName(pszFolderPath, NULL, IID_PPV_ARGS(&psiFolder));")
cpp_quote("    if (SUCCEEDED(hr))")
cpp_quote("    {")
cpp_quote("        IShellItem *psiSavedTo;")
cpp_quote("        hr = plib->Save(psiFolder, pszLibraryName, lsf, &psiSavedTo);")
cpp_quote("        if (SUCCEEDED(hr))")
cpp_quote("        {")
cpp_quote("            if (ppszSavedToPath)")
cpp_quote("            {")
cpp_quote("                hr = psiSavedTo->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, ppszSavedToPath);")
cpp_quote("            }")
cpp_quote("            psiSavedTo->Release();")
cpp_quote("        }")
cpp_quote("        psiFolder->Release();")
cpp_quote("    }")
cpp_quote("    return hr;")
cpp_quote("}")
cpp_quote("#endif  // __cplusplus")
cpp_quote("#endif  // _WIN32_IE >= _WIN32_IE_IE70")
cpp_quote("#endif  // NTDDI_WIN7")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_VISTA)")
//
//  SHAssocEnumHandlers returns an IEnumAssocHandlers object.
//
// Invoke an associated app handler
[
    uuid(92218CAB-ECAA-4335-8133-807FD234C2EE),
    object,
    pointer_default(unique),
    local
]
interface IAssocHandlerInvoker : IUnknown
{
    // Returns S_OK if selection is supported, S_FALSE if not.
    HRESULT SupportsSelection();

    HRESULT Invoke();
};

// Enumerate handlers
[
    uuid(F04061AC-1659-4a3f-A954-775AA57FC083),
    object,
    pointer_default(unique),
    local
]
interface IAssocHandler : IUnknown
{
    HRESULT GetName([string, out, annotation("__deref_out")] LPWSTR *ppsz);

    HRESULT GetUIName([string, out, annotation("__deref_out")] LPWSTR *ppsz);

    HRESULT GetIconLocation(
        [string, out, annotation("__deref_out")] LPWSTR *ppszPath,
        [out, annotation("__out")] int *pIndex);

    HRESULT IsRecommended();

    HRESULT MakeDefault([in, string, annotation("__in")] LPCWSTR pszDescription);

    HRESULT Invoke([in, annotation("__in")] IDataObject *pdo);

    HRESULT CreateInvoker(
        [in, annotation("__in")] IDataObject *pdo,
        [out, annotation("__deref_out")] IAssocHandlerInvoker **ppInvoker);
};

// Enumerate handlers
[
    uuid(973810ae-9599-4b88-9e4d-6ee98c9552da),
    object,
    pointer_default(unique),
    local
]
interface IEnumAssocHandlers : IUnknown
{
    HRESULT Next(
        [in, annotation("__in")] ULONG celt,
        [out, size_is(celt), length_is(*pceltFetched), annotation("__out_ecount_part(celt, *pceltFetched)")] IAssocHandler **rgelt,
        [out, annotation("__out_range(0,celt) __exceptthat __maybenull")] ULONG *pceltFetched);
};

enum _ASSOC_FILTER 
{
    ASSOC_FILTER_NONE        = 0x0,
    ASSOC_FILTER_RECOMMENDED = 0x1,
};
typedef int ASSOC_FILTER;

cpp_quote("SHSTDAPI SHAssocEnumHandlers(__in LPCWSTR pszExtra, __in ASSOC_FILTER afFilter, __deref_out IEnumAssocHandlers **ppEnumHandler);")
cpp_quote("#endif  // NTDDI_VISTA")

cpp_quote("#if (NTDDI_VERSION >= NTDDI_WIN7)")
cpp_quote("SHSTDAPI SHAssocEnumHandlersForProtocolByApplication(__in PCWSTR protocol, __in REFIID riid, __deref_out void **enumHandlers);")
cpp_quote("#endif  // NTDDI_WIN7")


