home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / sdk / winh / win95 / shlobj.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-11  |  46.5 KB  |  1,214 lines

  1. //===========================================================================
  2. //
  3. // Copyright (c) Microsoft Corporation 1991-1995
  4. //
  5. // File: shlobj.h
  6. //
  7. //===========================================================================
  8.  
  9. #ifndef _SHLOBJ_H_
  10. #define _SHLOBJ_H_
  11.  
  12. //
  13. // Define API decoration for direct importing of DLL references.
  14. //
  15. #ifndef WINSHELLAPI
  16. #if !defined(_SHELL32_)
  17. #define WINSHELLAPI DECLSPEC_IMPORT
  18. #else
  19. #define WINSHELLAPI
  20. #endif
  21. #endif // WINSHELLAPI
  22.  
  23. #include <ole2.h>
  24. #ifndef _PRSHT_H_
  25. #include <prsht.h>
  26. #endif
  27. #ifndef _INC_COMMCTRL
  28. #include <commctrl.h>    // for LPTBBUTTON
  29. #endif
  30.  
  31. #ifndef INITGUID
  32. #include <shlguid.h>
  33. #endif /* !INITGUID */
  34.  
  35. #ifndef RC_INVOKED
  36. #pragma pack(1)         /* Assume byte packing throughout */
  37. #endif /* !RC_INVOKED */
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {            /* Assume C declarations for C++ */
  41. #endif  /* __cplusplus */
  42.  
  43. //===========================================================================
  44. //
  45. // Object identifiers in the explorer's name space (ItemID and IDList)
  46. //
  47. //  All the items that the user can browse with the explorer (such as files,
  48. // directories, servers, work-groups, etc.) has an identifier which is unique
  49. // among items within the parent folder. Those identifiers are called item
  50. // IDs (SHITEMID). Since all its parent folders have their own item IDs,
  51. // any items can be uniquely identified by a list of item IDs, which is called
  52. // an ID list (ITEMIDLIST).
  53. //
  54. //  ID lists are almost always allocated by the task allocator (see some
  55. // description below as well as OLE 2.0 SDK) and may be passed across
  56. // some of shell interfaces (such as IShellFolder). Each item ID in an ID list
  57. // is only meaningful to its parent folder (which has generated it), and all
  58. // the clients must treat it as an opaque binary data except the first two
  59. // bytes, which indicates the size of the item ID.
  60. //
  61. //  When a shell extension -- which implements the IShellFolder interace --
  62. // generates an item ID, it may put any information in it, not only the data
  63. // with that it needs to identifies the item, but also some additional
  64. // information, which would help implementing some other functions efficiently.
  65. // For example, the shell's IShellFolder implementation of file system items
  66. // stores the primary (long) name of a file or a directory as the item
  67. // identifier, but it also stores its alternative (short) name, size and date
  68. // etc.
  69. //
  70. //  When an ID list is passed to one of shell APIs (such as SHGetPathFromIDList),
  71. // it is always an absolute path -- relative from the root of the name space,
  72. // which is the desktop folder. When an ID list is passed to one of IShellFolder
  73. // member function, it is always a relative path from the folder (unless it
  74. // is explicitly specified).
  75. //
  76. //===========================================================================
  77.  
  78. //
  79. // SHITEMID -- Item ID
  80. //
  81. typedef struct _SHITEMID    // mkid
  82. {
  83.     USHORT    cb;        // Size of the ID (including cb itself)
  84.     BYTE    abID[1];    // The item ID (variable length)
  85. } SHITEMID, * LPSHITEMID;
  86. typedef const SHITEMID  * LPCSHITEMID;
  87.  
  88. //
  89. // ITEMIDLIST -- List if item IDs (combined with 0-terminator)
  90. //
  91. typedef struct _ITEMIDLIST    // idl
  92. {
  93.     SHITEMID    mkid;
  94. } ITEMIDLIST, * LPITEMIDLIST;
  95. typedef const ITEMIDLIST * LPCITEMIDLIST;
  96.  
  97. //===========================================================================
  98. //
  99. // Task allocator API
  100. //
  101. //  All the shell extensions MUST use the task allocator (see OLE 2.0
  102. // programming guild for its definition) when they allocate or free
  103. // memory objects (mostly ITEMIDLIST) that are returned across any
  104. // shell interfaces. There are two ways to access the task allocator
  105. // from a shell extension depending on whether or not it is linked with
  106. // OLE32.DLL or not (purely for efficiency).
  107. //
  108. // (1) A shell extension which calls any OLE API (i.e., linked with
  109. //  OLE32.DLL) should call OLE's task allocator (by retrieving
  110. //  the task allocator by calling CoGetMalloc API).
  111. //
  112. // (2) A shell extension which does not call any OLE API (i.e., not linked
  113. //  with OLE32.DLL) should call the shell task allocator API (defined
  114. //  below), so that the shell can quickly loads it when OLE32.DLL is not
  115. //  loaded by any application at that point.
  116. //
  117. // Notes:
  118. //  In next version of Windowso release, SHGetMalloc will be replaced by
  119. // the following macro.
  120. //
  121. // #define SHGetMalloc(ppmem)    CoGetMalloc(MEMCTX_TASK, ppmem)
  122. //
  123. //===========================================================================
  124.  
  125. WINSHELLAPI HRESULT WINAPI SHGetMalloc(LPMALLOC * ppMalloc);
  126.  
  127. //===========================================================================
  128. //
  129. // IContextMenu interface
  130. //
  131. // [OverView]
  132. //
  133. //  The shell uses the IContextMenu interface in following three cases.
  134. //
  135. // case-1: The shell is loading context menu extensions.
  136. //
  137. //   When the user clicks the right mouse button on an item within the shell's
  138. //  name space (i.g., file, directory, server, work-group, etc.), it creates
  139. //  the default context menu for its type, then loads context menu extensions
  140. //  that are registered for that type (and its base type) so that they can
  141. //  add extra menu items. Those context menu extensions are registered at
  142. //  HKCR\{ProgID}\shellex\ContextMenuHandlers.
  143. //
  144. // case-2: The shell is retrieving a context menu of sub-folders in extended
  145. //   name-space.
  146. //
  147. //   When the explorer's name space is extended by name space extensions,
  148. //  the shell calls their IShellFolder::GetUIObjectOf to get the IContextMenu
  149. //  objects when it creates context menus for folders under those extended
  150. //  name spaces.
  151. //
  152. // case-3: The shell is loading non-default drag and drop handler for directories.
  153. //
  154. //   When the user performed a non-default drag and drop onto one of file
  155. //  system folders (i.e., directories), it loads shell extensions that are
  156. //  registered at HKCR\{ProgID}\DragDropHandlers.
  157. //
  158. //
  159. // [Member functions]
  160. //
  161. //
  162. // IContextMenu::QueryContextMenu
  163. //
  164. //   This member function may insert one or more menuitems to the specified
  165. //  menu (hmenu) at the specified location (indexMenu which is never be -1).
  166. //  The IDs of those menuitem must be in the specified range (idCmdFirst and
  167. //  idCmdLast). It returns the maximum menuitem ID offset (ushort) in the
  168. //  'code' field (low word) of the scode.
  169. //
  170. //   The uFlags specify the context. It may have one or more of following
  171. //  flags.
  172. //
  173. //  CMF_DEFAULTONLY: This flag is passed if the user is invoking the default
  174. //   action (typically by double-clicking, case 1 and 2 only). Context menu
  175. //   extensions (case 1) should not add any menu items, and returns NOERROR.
  176. //
  177. //  CMF_VERBSONLY: The explorer passes this flag if it is constructing
  178. //   a context menu for a short-cut object (case 1 and case 2 only). If this
  179. //   flag is passed, it should not add any menu-items that is not appropriate
  180. //   from a short-cut.
  181. //    A good example is the "Delete" menuitem, which confuses the user
  182. //   because it is not clear whether it deletes the link source item or the
  183. //   link itself.
  184. //
  185. //  CMF_EXPLORER: The explorer passes this flag if it has the left-side pane
  186. //   (case 1 and 2 only). Context menu extensions should ignore this flag.
  187. //
  188. //   High word (16-bit) are reserved for context specific communications
  189. //  and the rest of flags (13-bit) are reserved by the system.
  190. //
  191. //
  192. // IContextMenu::InvokeCommand
  193. //
  194. //   This member is called when the user has selected one of menuitems that
  195. //  are inserted by previous QueryContextMenu member. In this case, the
  196. //  LOWORD(lpici->lpVerb) contains the menuitem ID offset (menuitem ID -
  197. //  idCmdFirst).
  198. //
  199. //   This member function may also be called programmatically. In such a case,
  200. //  lpici->lpVerb specifies the canonical name of the command to be invoked,
  201. //  which is typically retrieved by GetCommandString member previously.
  202. //
  203. //  Parameters in lpci:
  204. //    cbSize -- Specifies the size of this structure (sizeof(*lpci))
  205. //    hwnd   -- Specifies the owner window for any message/dialog box.
  206. //    fMask  -- Specifies whether or not dwHotkey/hIcon paramter is valid.
  207. //    lpVerb -- Specifies the command to be invoked.
  208. //    lpParameters -- Parameters (optional)
  209. //    lpDirectory  -- Working directory (optional)
  210. //    nShow -- Specifies the flag to be passed to ShowWindow (SW_*).
  211. //    dwHotKey -- Hot key to be assigned to the app after invoked (optional).
  212. //    hIcon -- Specifies the icon (optional).
  213. //
  214. //
  215. // IContextMenu::GetCommandString
  216. //
  217. //   This member function is called by the explorer either to get the
  218. //  canonical (language independent) command name (uFlags == GCS_VERB) or
  219. //  the help text ((uFlags & GCS_HELPTEXT) != 0) for the specified command.
  220. //  The retrieved canonical string may be passed to its InvokeCommand
  221. //  member function to invoke a command programmatically. The explorer
  222. //  displays the help texts in its status bar; therefore, the length of
  223. //  the help text should be reasonably short (<40 characters).
  224. //
  225. //  Parameters:
  226. //   idCmd -- Specifies menuitem ID offset (from idCmdFirst)
  227. //   uFlags -- Either GCS_VERB or GCS_HELPTEXT
  228. //   pwReserved -- Reserved (must pass NULL when calling, must ignore when called)
  229. //   pszName -- Specifies the string buffer.
  230. //   cchMax -- Specifies the size of the string buffer.
  231. //
  232. //===========================================================================
  233.  
  234. #undef  INTERFACE
  235. #define INTERFACE   IContextMenu
  236.  
  237. // QueryContextMenu uFlags
  238. #define CMF_NORMAL         0x00000000
  239. #define CMF_DEFAULTONLY      0x00000001
  240. #define CMF_VERBSONLY        0x00000002
  241. #define CMF_EXPLORE         0x00000004
  242. #define CMF_RESERVED         0xffff0000    // View specific
  243.  
  244. // GetCommandString uFlags
  245. #define GCS_VERB         0x00000000     // canonical verb
  246. #define GCS_HELPTEXT     0x00000001    // help text (for status bar)
  247. #define GCS_VALIDATE     0x00000002    // validate command exists
  248.  
  249. #define CMDSTR_NEWFOLDER     "NewFolder"
  250. #define CMDSTR_VIEWLIST      "ViewList"
  251. #define CMDSTR_VIEWDETAILS   "ViewDetails"
  252.  
  253. #define CMIC_MASK_HOTKEY    SEE_MASK_HOTKEY
  254. #define CMIC_MASK_ICON        SEE_MASK_ICON
  255. #define CMIC_MASK_FLAG_NO_UI    SEE_MASK_FLAG_NO_UI
  256. #define CMIC_MASK_MODAL         0x80000000                /* ; Internal */
  257.  
  258. #define CMIC_VALID_SEE_FLAGS    SEE_VALID_CMIC_FLAGS            /* ; Internal */
  259.  
  260. typedef struct _CMInvokeCommandInfo {
  261.     DWORD cbSize;     // must be sizeof(CMINVOKECOMMANDINFO)
  262.     DWORD fMask;     // any combination of CMIC_MASK_*
  263.     HWND hwnd;         // might be NULL (indicating no owner window)
  264.     LPCSTR lpVerb;     // either a string of MAKEINTRESOURCE(idOffset)
  265.     LPCSTR lpParameters; // might be NULL (indicating no parameter)
  266.     LPCSTR lpDirectory;     // might be NULL (indicating no specific directory)
  267.     int nShow;         // one of SW_ values for ShowWindow() API
  268.  
  269.     DWORD dwHotKey;
  270.     HANDLE hIcon;
  271. } CMINVOKECOMMANDINFO,  *LPCMINVOKECOMMANDINFO;
  272.  
  273. #undef  INTERFACE
  274. #define INTERFACE   IContextMenu
  275.  
  276. DECLARE_INTERFACE_(IContextMenu, IUnknown)
  277. {
  278.     // *** IUnknown methods ***
  279.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  280.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  281.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  282.  
  283.     STDMETHOD(QueryContextMenu)(THIS_
  284.                                 HMENU hmenu,
  285.                                 UINT indexMenu,
  286.                                 UINT idCmdFirst,
  287.                                 UINT idCmdLast,
  288.                                 UINT uFlags) PURE;
  289.  
  290.     STDMETHOD(InvokeCommand)(THIS_
  291.                              LPCMINVOKECOMMANDINFO lpici) PURE;
  292.  
  293.     STDMETHOD(GetCommandString)(THIS_
  294.                                 UINT        idCmd,
  295.                                 UINT        uType,
  296.                                 UINT      * pwReserved,
  297.                                 LPSTR       pszName,
  298.                                 UINT        cchMax) PURE;
  299. };
  300.  
  301. typedef IContextMenu *    LPCONTEXTMENU;
  302.  
  303. //===========================================================================
  304. //
  305. // Interface: IShellExtInit
  306. //
  307. //  The IShellExtInit interface is used by the explorer to initialize shell
  308. // extension objects. The explorer (1) calls CoCreateInstance (or equivalent)
  309. // with the registered CLSID and IID_IShellExtInit, (2) calls its Initialize
  310. // member, then (3) calls its QueryInterface to a particular interface (such
  311. // as IContextMenu or IPropSheetExt and (4) performs the rest of operation.
  312. //
  313. //
  314. // [Member functions]
  315. //
  316. // IShellExtInit::Initialize
  317. //
  318. //  This member function is called when the explorer is initializing either
  319. // context menu extension, property sheet extension or non-default drag-drop
  320. // extension.
  321. //
  322. //  Parameters: (context menu or property sheet extension)
  323. //   pidlFolder -- Specifies the parent folder
  324. //   lpdobj -- Spefifies the set of items selected in that folder.
  325. //   hkeyProgID -- Specifies the type of the focused item in the selection.
  326. //
  327. //  Parameters: (non-default drag-and-drop extension)
  328. //   pidlFolder -- Specifies the target (destination) folder
  329. //   lpdobj -- Specifies the items that are dropped (see the description
  330. //    about shell's clipboard below for clipboard formats).
  331. //   hkeyProgID -- Specifies the folder type.
  332. //
  333. //===========================================================================
  334.  
  335. #undef  INTERFACE
  336. #define INTERFACE   IShellExtInit
  337.  
  338. DECLARE_INTERFACE_(IShellExtInit, IUnknown)
  339. {
  340.     // *** IUnknown methods ***
  341.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  342.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  343.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  344.  
  345.     // *** IShellExtInit methods ***
  346.     STDMETHOD(Initialize)(THIS_ LPCITEMIDLIST pidlFolder,
  347.                   LPDATAOBJECT lpdobj, HKEY hkeyProgID) PURE;
  348. };
  349.  
  350. typedef IShellExtInit *    LPSHELLEXTINIT;
  351.  
  352. //===========================================================================
  353. //
  354. // Interface: IShellPropSheetExt
  355. //
  356. //  The explorer uses the IShellPropSheetExt to allow property sheet
  357. // extensions or control panel extensions to add additional property
  358. // sheet pages.
  359. //
  360. //
  361. // [Member functions]
  362. //
  363. // IShellPropSheetExt::AddPages
  364. //
  365. //  The explorer calls this member function when it finds a registered
  366. // property sheet extension for a particular type of object. For each
  367. // additional page, the extension creates a page object by calling
  368. // CreatePropertySheetPage API and calls lpfnAddPage.
  369. //
  370. //  Parameters:
  371. //   lpfnAddPage -- Specifies the callback function.
  372. //   lParam -- Specifies the opaque handle to be passed to the callback function.
  373. //
  374. //
  375. // IShellPropSheetExt::ReplacePage
  376. //
  377. //  The explorer never calls this member of property sheet extensions. The
  378. // explorer calls this member of control panel extensions, so that they
  379. // can replace some of default control panel pages (such as a page of
  380. // mouse control panel).
  381. //
  382. //  Parameters:
  383. //   uPageID -- Specifies the page to be replaced.
  384. //   lpfnReplace Specifies the callback function.
  385. //   lParam -- Specifies the opaque handle to be passed to the callback function.
  386. //
  387. //===========================================================================
  388.  
  389. #undef  INTERFACE
  390. #define INTERFACE   IShellPropSheetExt
  391.  
  392. DECLARE_INTERFACE_(IShellPropSheetExt, IUnknown)
  393. {
  394.     // *** IUnknown methods ***
  395.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  396.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  397.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  398.  
  399.     // *** IShellPropSheetExt methods ***
  400.     STDMETHOD(AddPages)(THIS_ LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam) PURE;
  401.     STDMETHOD(ReplacePage)(THIS_ UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam) PURE;
  402. };
  403.  
  404. typedef IShellPropSheetExt * LPSHELLPROPSHEETEXT;
  405.  
  406. //===========================================================================
  407. //
  408. // IExtractIcon interface
  409. //
  410. //  This interface is used in two different places in the shell.
  411. //
  412. // Case-1: Icons of sub-folders for the scope-pane of the explorer.
  413. //
  414. //  It is used by the explorer to get the "icon location" of
  415. // sub-folders from each shell folders. When the user expands a folder
  416. // in the scope pane of the explorer, the explorer does following:
  417. //  (1) binds to the folder (gets IShellFolder),
  418. //  (2) enumerates its sub-folders by calling its EnumObjects member,
  419. //  (3) calls its GetUIObjectOf member to get IExtractIcon interface
  420. //     for each sub-folders.
  421. //  In this case, the explorer uses only IExtractIcon::GetIconLocation
  422. // member to get the location of the appropriate icon. An icon location
  423. // always consists of a file name (typically DLL or EXE) and either an icon
  424. // resource or an icon index.
  425. //
  426. //
  427. // Case-2: Extracting an icon image from a file
  428. //
  429. //  It is used by the shell when it extracts an icon image
  430. // from a file. When the shell is extracting an icon from a file,
  431. // it does following:
  432. //  (1) creates the icon extraction handler object (by getting its CLSID
  433. //     under the {ProgID}\shell\ExtractIconHanler key and calling
  434. //     CoCreateInstance requesting for IExtractIcon interface).
  435. //  (2) Calls IExtractIcon::GetIconLocation.
  436. //  (3) Then, calls IExtractIcon::Extract with the location/index pair.
  437. //  (4) If (3) returns NOERROR, it uses the returned icon.
  438. //  (5) Otherwise, it recursively calls this logic with new location
  439. //     assuming that the location string contains a fully qualified path name.
  440. //
  441. //  From extension programmer's point of view, there are only two cases
  442. // where they provide implementations of IExtractIcon:
  443. //  Case-1) providing explorer extensions (i.e., IShellFolder).
  444. //  Case-2) providing per-instance icons for some types of files.
  445. //
  446. // Because Case-1 is described above, we'll explain only Case-2 here.
  447. //
  448. // When the shell is about display an icon for a file, it does following:
  449. //  (1) Finds its ProgID and ClassID.
  450. //  (2) If the file has a ClassID, it gets the icon location string from the
  451. //    "DefaultIcon" key under it. The string indicates either per-class
  452. //    icon (e.g., "FOOBAR.DLL,2") or per-instance icon (e.g., "%1,1").
  453. //  (3) If a per-instance icon is specified, the shell creates an icon
  454. //    extraction handler object for it, and extracts the icon from it
  455. //    (which is described above).
  456. //
  457. //  It is important to note that the shell calls IExtractIcon::GetIconLocation
  458. // first, then calls IExtractIcon::Extract. Most application programs
  459. // that support per-instance icons will probably store an icon location
  460. // (DLL/EXE name and index/id) rather than an icon image in each file.
  461. // In those cases, a programmer needs to implement only the GetIconLocation
  462. // member and it Extract member simply returns S_FALSE. They need to
  463. // implement Extract member only if they decided to store the icon images
  464. // within files themselved or some other database (which is very rare).
  465. //
  466. //
  467. //
  468. // [Member functions]
  469. //
  470. //
  471. // IExtractIcon::GetIconLocation
  472. //
  473. //  This function returns an icon location.
  474. //
  475. //  Parameters:
  476. //   uFlags     [in]  -- Specifies if it is opened or not (GIL_OPENICON or 0)
  477. //   szIconFile [out] -- Specifies the string buffer buffer for a location name.
  478. //   cchMax     [in]  -- Specifies the size of szIconFile (almost always MAX_PATH)
  479. //   piIndex    [out] -- Sepcifies the address of UINT for the index.
  480. //   pwFlags    [out] -- Returns GIL_* flags
  481. //  Returns:
  482. //   NOERROR, if it returns a valid location; S_FALSE, if the shell use a
  483. //   default icon.
  484. //
  485. //  Notes: The location may or may not be a path to a file. The caller can
  486. //   not assume anything unless the subsequent Extract member call returns
  487. //   S_FALSE.
  488. //
  489. //   if the returned location is not a path to a file, GIL_NOTFILENAME should
  490. //   be set in the returned flags.
  491. //
  492. // IExtractIcon::Extract
  493. //
  494. //  This function extracts an icon image from a specified file.
  495. //
  496. //  Parameters:
  497. //   pszFile [in] -- Specifies the icon location (typically a path to a file).
  498. //   nIconIndex [in] -- Specifies the icon index.
  499. //   phiconLarge [out] -- Specifies the HICON variable for large icon.
  500. //   phiconSmall [out] -- Specifies the HICON variable for small icon.
  501. //   nIconSize [in] -- Specifies the size icon required (size of large icon)
  502. //                     LOWORD is the requested large icon size
  503. //                     HIWORD is the requested small icon size
  504. //  Returns:
  505. //   NOERROR, if it extracted the from the file.
  506. //   S_FALSE, if the caller should extract from the file specified in the
  507. //           location.
  508. //
  509. //===========================================================================
  510.  
  511. #undef  INTERFACE
  512. #define INTERFACE   IExtractIcon
  513.  
  514. // GetIconLocation() input flags
  515.  
  516. #define GIL_OPENICON     0x0001      // allows containers to specify an "open" look
  517. #define GIL_FORSHELL     0x0002      // icon is to be displayed in a ShellFolder
  518.  
  519. // GetIconLocation() return flags
  520.  
  521. #define GIL_SIMULATEDOC  0x0001      // simulate this document icon for this
  522. #define GIL_PERINSTANCE  0x0002      // icons from this class are per instance (each file has its own)
  523. #define GIL_PERCLASS     0x0004      // icons from this class per class (shared for all files of this type)
  524. #define GIL_NOTFILENAME  0x0008      // location is not a filename, must call ::Extract
  525. #define GIL_DONTCACHE    0x0010      // this icon should not be cached
  526.  
  527. DECLARE_INTERFACE_(IExtractIcon, IUnknown)    // exic
  528. {
  529.     // *** IUnknown methods ***
  530.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  531.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  532.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  533.  
  534.     // *** IExtractIcon methods ***
  535.     STDMETHOD(GetIconLocation)(THIS_
  536.                          UINT   uFlags,
  537.                          LPSTR  szIconFile,
  538.                          UINT   cchMax,
  539.                          int   * piIndex,
  540.                          UINT  * pwFlags) PURE;
  541.  
  542.     STDMETHOD(Extract)(THIS_
  543.                            LPCSTR pszFile,
  544.                UINT      nIconIndex,
  545.                HICON   *phiconLarge,
  546.                            HICON   *phiconSmall,
  547.                            UINT    nIconSize) PURE;
  548. };
  549.  
  550. typedef IExtractIcon *  LPEXTRACTICON;
  551.  
  552. //===========================================================================
  553. //
  554. // IShellLink Interface
  555. //
  556. //===========================================================================
  557.  
  558. // IShellLink::Resolve fFlags
  559. typedef enum {
  560.     SLR_NO_UI        = 0x0001,
  561.     SLR_ANY_MATCH    = 0x0002,
  562.     SLR_UPDATE          = 0x0004,
  563. } SLR_FLAGS;
  564.  
  565. // IShellLink::GetPath fFlags
  566. typedef enum {
  567.     SLGP_SHORTPATH    = 0x0001,
  568.     SLGP_UNCPRIORITY    = 0x0002,
  569. } SLGP_FLAGS;
  570.  
  571. #undef  INTERFACE
  572. #define INTERFACE   IShellLink
  573.  
  574. DECLARE_INTERFACE_(IShellLink, IUnknown)    // sl
  575. {
  576.     // *** IUnknown methods ***
  577.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  578.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  579.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  580.  
  581.     STDMETHOD(GetPath)(THIS_ LPSTR pszFile, int cchMaxPath, WIN32_FIND_DATA *pfd, DWORD fFlags) PURE;
  582.  
  583.     STDMETHOD(GetIDList)(THIS_ LPITEMIDLIST * ppidl) PURE;
  584.     STDMETHOD(SetIDList)(THIS_ LPCITEMIDLIST pidl) PURE;
  585.  
  586.     STDMETHOD(GetDescription)(THIS_ LPSTR pszName, int cchMaxName) PURE;
  587.     STDMETHOD(SetDescription)(THIS_ LPCSTR pszName) PURE;
  588.  
  589.     STDMETHOD(GetWorkingDirectory)(THIS_ LPSTR pszDir, int cchMaxPath) PURE;
  590.     STDMETHOD(SetWorkingDirectory)(THIS_ LPCSTR pszDir) PURE;
  591.  
  592.     STDMETHOD(GetArguments)(THIS_ LPSTR pszArgs, int cchMaxPath) PURE;
  593.     STDMETHOD(SetArguments)(THIS_ LPCSTR pszArgs) PURE;
  594.  
  595.     STDMETHOD(GetHotkey)(THIS_ WORD *pwHotkey) PURE;
  596.     STDMETHOD(SetHotkey)(THIS_ WORD wHotkey) PURE;
  597.  
  598.     STDMETHOD(GetShowCmd)(THIS_ int *piShowCmd) PURE;
  599.     STDMETHOD(SetShowCmd)(THIS_ int iShowCmd) PURE;
  600.  
  601.     STDMETHOD(GetIconLocation)(THIS_ LPSTR pszIconPath, int cchIconPath, int *piIcon) PURE;
  602.     STDMETHOD(SetIconLocation)(THIS_ LPCSTR pszIconPath, int iIcon) PURE;
  603.  
  604.     STDMETHOD(SetRelativePath)(THIS_ LPCSTR pszPathRel, DWORD dwReserved) PURE;
  605.  
  606.     STDMETHOD(Resolve)(THIS_ HWND hwnd, DWORD fFlags) PURE;
  607.  
  608.     STDMETHOD(SetPath)(THIS_ LPCSTR pszFile) PURE;
  609. };
  610.  
  611. //===========================================================================
  612. //
  613. // ICopyHook Interface
  614. //
  615. //
  616. //  The copy hook is called whenever file system directories are
  617. //  copy/moved/deleted/renamed via the shell.  It is also called by the shell
  618. //  on changes of status of printers.
  619. //
  620. //  Clients register their id under STRREG_SHEX_COPYHOOK for file system hooks
  621. //  and STRREG_SHEx_PRNCOPYHOOK for printer hooks.
  622. //  the CopyCallback is called prior to the action, so the hook has the chance
  623. //  to allow, deny or cancel the operation by returning the falues:
  624. //     IDYES  -  means allow the operation
  625. //     IDNO   -  means disallow the operation on this file, but continue with
  626. //              any other operations (eg. batch copy)
  627. //     IDCANCEL - means disallow the current operation and cancel any pending
  628. //              operations
  629. //
  630. //   arguments to the CopyCallback
  631. //      hwnd - window to use for any UI
  632. //      wFunc - what operation is being done
  633. //      wFlags - and flags (FOF_*) set in the initial call to the file operation
  634. //      pszSrcFile - name of the source file
  635. //      dwSrcAttribs - file attributes of the source file
  636. //      pszDestFile - name of the destiation file (for move and renames)
  637. //      dwDestAttribs - file attributes of the destination file
  638. //
  639. //
  640. //===========================================================================
  641.  
  642. #undef  INTERFACE
  643. #define INTERFACE   ICopyHook
  644.  
  645. #ifndef FO_MOVE //these need to be kept in sync with the ones in shellapi.h
  646.  
  647. // file operations
  648.  
  649. #define FO_MOVE           0x0001
  650. #define FO_COPY           0x0002
  651. #define FO_DELETE         0x0003
  652. #define FO_RENAME         0x0004
  653.  
  654. #define FOF_MULTIDESTFILES         0x0001
  655. #define FOF_CONFIRMMOUSE           0x0002
  656. #define FOF_SILENT                 0x0004  // don't create progress/report
  657. #define FOF_RENAMEONCOLLISION      0x0008
  658. #define FOF_NOCONFIRMATION         0x0010  // Don't prompt the user.
  659. #define FOF_WANTMAPPINGHANDLE      0x0020  // Fill in SHFILEOPSTRUCT.hNameMappings
  660.                                       // Must be freed using SHFreeNameMappings
  661. #define FOF_ALLOWUNDO              0x0040
  662. #define FOF_FILESONLY              0x0080  // on *.*, do only files
  663. #define FOF_SIMPLEPROGRESS         0x0100  // means don't show names of files
  664. #define FOF_NOCONFIRMMKDIR         0x0200  // don't confirm making any needed dirs
  665.  
  666. typedef UINT FILEOP_FLAGS;
  667.  
  668. // printer operations
  669.  
  670. #define PO_DELETE    0x0013  // printer is being deleted
  671. #define PO_RENAME    0x0014  // printer is being renamed
  672. #define PO_PORTCHANGE    0x0020  // port this printer connected to is being changed
  673.                 // if this id is set, the strings received by
  674.                 // the copyhook are a doubly-null terminated
  675.                 // list of strings.  The first is the printer
  676.                 // name and the second is the printer port.
  677. #define PO_REN_PORT    0x0034  // PO_RENAME and PO_PORTCHANGE at same time.
  678.  
  679. // no POF_ flags currently defined
  680.  
  681. typedef UINT PRINTEROP_FLAGS;
  682.  
  683. #endif // FO_MOVE
  684.  
  685. DECLARE_INTERFACE_(ICopyHook, IUnknown)    // sl
  686. {
  687.     // *** IUnknown methods ***
  688.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  689.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  690.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  691.  
  692.     STDMETHOD_(UINT,CopyCallback) (THIS_ HWND hwnd, UINT wFunc, UINT wFlags, LPCSTR pszSrcFile, DWORD dwSrcAttribs,
  693.                                    LPCSTR pszDestFile, DWORD dwDestAttribs) PURE;
  694. };
  695.  
  696. typedef ICopyHook *    LPCOPYHOOK;
  697.  
  698. //===========================================================================
  699. //
  700. // IFileViewerSite Interface
  701. //
  702. //===========================================================================
  703.  
  704. #undef  INTERFACE
  705. #define INTERFACE   IFileViewerSite
  706.  
  707. DECLARE_INTERFACE(IFileViewerSite)
  708. {
  709.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  710.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  711.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  712.  
  713.     STDMETHOD(SetPinnedWindow) (THIS_ HWND hwnd) PURE;
  714.     STDMETHOD(GetPinnedWindow) (THIS_ HWND *phwnd) PURE;
  715. };
  716.  
  717. typedef IFileViewerSite * LPFILEVIEWERSITE;
  718.  
  719. //===========================================================================
  720. //
  721. // IFileViewer Interface
  722. //
  723. // Implemented in a FileViewer component object.  Used to tell a
  724. // FileViewer to PrintTo or to view, the latter happening though
  725. // ShowInitialize and Show.  The filename is always given to the
  726. // viewer through IPersistFile.
  727. //
  728. //===========================================================================
  729.  
  730. #undef  INTERFACE
  731. #define INTERFACE   IFileViewer
  732.  
  733. typedef struct
  734. {
  735.     // Stuff passed into viewer (in)
  736.     DWORD cbSize;           // Size of structure for future expansion...
  737.     HWND hwndOwner;         // who is the owner window.
  738.     int iShow;              // The show command
  739.  
  740.     // Passed in and updated  (in/Out)
  741.     DWORD dwFlags;          // flags
  742.     RECT rect;              // Where to create the window may have defaults
  743.     LPUNKNOWN punkRel;      // Relese this interface when window is visible
  744.  
  745.     // Stuff that might be returned from viewer (out)
  746.     OLECHAR strNewFile[MAX_PATH];   // New File to view.
  747.  
  748. } FVSHOWINFO, *LPFVSHOWINFO;
  749.  
  750.     // Define File View Show Info Flags.
  751. #define FVSIF_RECT      0x00000001      // The rect variable has valid data.
  752. #define FVSIF_PINNED    0x00000002      // We should Initialize pinned
  753.  
  754. #define FVSIF_NEWFAILED 0x08000000      // The new file passed back failed
  755.                                         // to be viewed.
  756.  
  757. #define FVSIF_NEWFILE   0x80000000      // A new file to view has been returned
  758. #define FVSIF_CANVIEWIT 0x40000000      // The viewer can view it.
  759.  
  760. DECLARE_INTERFACE(IFileViewer)
  761. {
  762.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  763.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  764.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  765.  
  766.     STDMETHOD(ShowInitialize) (THIS_ LPFILEVIEWERSITE lpfsi) PURE;
  767.     STDMETHOD(Show) (THIS_ LPFVSHOWINFO pvsi) PURE;
  768.     STDMETHOD(PrintTo) (THIS_ LPSTR pszDriver, BOOL fSuppressUI) PURE;
  769. };
  770.  
  771. typedef IFileViewer * LPFILEVIEWER;
  772.  
  773. //-------------------------------------------------------------------------
  774. //
  775. // struct STRRET
  776. //
  777. // structure for returning strings from IShellFolder member functions
  778. //
  779. //-------------------------------------------------------------------------
  780. #define STRRET_WSTR    0x0000
  781. #define STRRET_OFFSET    0x0001
  782. #define STRRET_CSTR    0x0002
  783.  
  784. typedef struct _STRRET
  785. {
  786.     UINT uType;    // One of the STRRET_* values
  787.     union
  788.     {
  789.         LPWSTR          pOleStr;        // OLESTR that will be freed
  790.         UINT            uOffset;        // Offset into SHITEMID (ANSI)
  791.         char            cStr[MAX_PATH]; // Buffer to fill in
  792.     } DUMMYUNIONNAME;
  793. } STRRET, *LPSTRRET;
  794.  
  795. //-------------------------------------------------------------------------
  796. //
  797. // SHGetPathFromIDList
  798. //
  799. //  This function assumes the size of the buffer (MAX_PATH). The pidl
  800. // should point to a file system object.
  801. //
  802. //-------------------------------------------------------------------------
  803.  
  804. WINSHELLAPI BOOL WINAPI SHGetPathFromIDList(LPCITEMIDLIST pidl, LPSTR pszPath);
  805.  
  806. //-------------------------------------------------------------------------
  807. //
  808. // SHGetSpecialFolderLocation
  809. //
  810. //  Returns a pidl to a predefined shell folder.  The caller must free the
  811. //   pidl.  Use SHGetMalloc to obtain an allocator that can free the pidl.
  812. //
  813. //-------------------------------------------------------------------------
  814. //
  815. // registry entries for special paths are kept in :
  816. #define REGSTR_PATH_SPECIAL_FOLDERS    REGSTR_PATH_EXPLORER "\\Shell Folders"
  817.  
  818. #define CSIDL_DESKTOP            0x0000
  819. #define CSIDL_PROGRAMS           0x0002
  820. #define CSIDL_CONTROLS           0x0003
  821. #define CSIDL_PRINTERS           0x0004
  822. #define CSIDL_PERSONAL           0x0005
  823. #define CSIDL_FAVORITES          0x0006
  824. #define CSIDL_STARTUP            0x0007
  825. #define CSIDL_RECENT             0x0008
  826. #define CSIDL_SENDTO             0x0009
  827. #define CSIDL_BITBUCKET          0x000a
  828. #define CSIDL_STARTMENU          0x000b
  829. #define CSIDL_DESKTOPDIRECTORY   0x0010
  830. #define CSIDL_DRIVES             0x0011
  831. #define CSIDL_NETWORK            0x0012
  832. #define CSIDL_NETHOOD            0x0013
  833. #define CSIDL_FONTS         0x0014
  834. #define CSIDL_TEMPLATES          0x0015
  835.  
  836. WINSHELLAPI HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, int nFolder, LPITEMIDLIST * ppidl);
  837.  
  838. //-------------------------------------------------------------------------
  839. //
  840. // SHBrowseForFolder API
  841. //
  842. //-------------------------------------------------------------------------
  843.  
  844. typedef int (CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
  845.  
  846. typedef struct _browseinfo {
  847.     HWND        hwndOwner;
  848.     LPCITEMIDLIST pidlRoot;
  849.     LPSTR        pszDisplayName;// Return display name of item selected.
  850.     LPCSTR       lpszTitle;      // text to go in the banner over the tree.
  851.     UINT         ulFlags;       // Flags that control the return stuff
  852.     BFFCALLBACK  lpfn;
  853.     LPARAM      lParam;         // extra info that's passed back in callbacks
  854.  
  855.     int          iImage;      // output var: where to return the Image index.
  856. } BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO;
  857.  
  858. // Browsing for directory.
  859. #define BIF_RETURNONLYFSDIRS   0x0001  // For finding a folder to start document searching
  860. #define BIF_DONTGOBELOWDOMAIN  0x0002  // For starting the Find Computer
  861. #define BIF_STATUSTEXT         0x0004
  862. #define BIF_RETURNFSANCESTORS  0x0008
  863.  
  864. #define BIF_BROWSEFORCOMPUTER  0x1000  // Browsing for Computers.
  865. #define BIF_BROWSEFORPRINTER   0x2000  // Browsing for Printers
  866.  
  867. // message from browser
  868. #define BFFM_INITIALIZED        1
  869. #define BFFM_SELCHANGED         2
  870.  
  871. // messages to browser
  872. #define BFFM_SETSTATUSTEXT      (WM_USER + 100)
  873. #define BFFM_ENABLEOK           (WM_USER + 101)
  874. #define BFFM_SETSELECTION       (WM_USER + 102)
  875.  
  876. WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(LPBROWSEINFO lpbi);
  877.  
  878. //-------------------------------------------------------------------------
  879. //
  880. // SHLoadInProc
  881. //
  882. //   When this function is called, the shell calls CoCreateInstance
  883. //  (or equivalent) with CLSCTX_INPROC_SERVER and the specified CLSID
  884. //  from within the shell's process and release it immediately.
  885. //
  886. //-------------------------------------------------------------------------
  887.  
  888. WINSHELLAPI HRESULT WINAPI SHLoadInProc(REFCLSID rclsid);
  889.  
  890. //-------------------------------------------------------------------------
  891. //
  892. // IEnumIDList interface
  893. //
  894. //  IShellFolder::EnumObjects member returns an IEnumIDList object.
  895. //
  896. //-------------------------------------------------------------------------
  897.  
  898. typedef struct IEnumIDList    *LPENUMIDLIST;
  899.  
  900. #undef     INTERFACE
  901. #define    INTERFACE     IEnumIDList
  902.  
  903. DECLARE_INTERFACE_(IEnumIDList, IUnknown)
  904. {
  905.     // *** IUnknown methods ***
  906.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  907.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  908.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  909.  
  910.     // *** IEnumIDList methods ***
  911.     STDMETHOD(Next)  (THIS_ ULONG celt,
  912.               LPITEMIDLIST *rgelt,
  913.               ULONG *pceltFetched) PURE;
  914.     STDMETHOD(Skip)  (THIS_ ULONG celt) PURE;
  915.     STDMETHOD(Reset) (THIS) PURE;
  916.     STDMETHOD(Clone) (THIS_ IEnumIDList **ppenum) PURE;
  917. };
  918.  
  919. //-------------------------------------------------------------------------
  920. //
  921. // IShellFolder interface
  922. //
  923. //
  924. // [Member functions]
  925. //
  926. // IShellFolder::BindToObject(pidl, pbc, riid, ppvOut)
  927. //   This function returns an instance of a sub-folder which is specified
  928. //  by the IDList (pidl).
  929. //
  930. // IShellFolder::BindToStorage(pidl, pbc, riid, ppvObj)
  931. //   This function returns a storage instance of a sub-folder which is
  932. //  specified by the IDList (pidl). The shell never calls this member
  933. //  function in the first release of Win95.
  934. //
  935. // IShellFolder::CompareIDs(lParam, pidl1, pidl2)
  936. //   This function compares two IDLists and returns the result. The shell
  937. //  explorer always passes 0 as lParam, which indicates "sort by name".
  938. //  It should return 0 (as CODE of the scode), if two id indicates the
  939. //  same object; negative value if pidl1 should be placed before pidl2;
  940. //  positive value if pidl2 should be placed before pidl1.
  941. //
  942. // IShellFolder::CreateViewObject(hwndOwner, riid, ppvOut)
  943. //   This function creates a view object of the folder itself. The view
  944. //  object is a difference instance from the shell folder object.
  945. //
  946. // IShellFolder::GetAttributesOf(cidl, apidl, prgfInOut)
  947. //   This function returns the attributes of specified objects in that
  948. //  folder. "cidl" and "apidl" specifies objects. "apidl" contains only
  949. //  simple IDLists. The explorer initializes *prgfInOut with a set of
  950. //  flags to be evaluated. The shell folder may optimize the operation
  951. //  by not returning unspecified flags.
  952. //
  953. // IShellFolder::GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut)
  954. //   This function creates a UI object to be used for specified objects.
  955. //  The shell explorer passes either IID_IDataObject (for transfer operation)
  956. //  or IID_IContextMenu (for context menu operation) as riid.
  957. //
  958. // IShellFolder::GetDisplayNameOf
  959. //   This function returns the display name of the specified object.
  960. //  If the ID contains the display name (in the locale character set),
  961. //  it returns the offset to the name. Otherwise, it returns a pointer
  962. //  to the display name string (UNICODE), which is allocated by the
  963. //  task allocator, or fills in a buffer.
  964. //
  965. // IShellFolder::SetNameOf
  966. //   This function sets the display name of the specified object.
  967. //  If it changes the ID as well, it returns the new ID which is
  968. //  alocated by the task allocator.
  969. //
  970. //-------------------------------------------------------------------------
  971.  
  972. #undef     INTERFACE
  973. #define    INTERFACE     IShellFolder
  974.  
  975. // IShellFolder::GetDisplayNameOf/SetNameOf uFlags
  976. typedef enum tagSHGDN
  977. {
  978.     SHGDN_NORMAL        = 0,    // default (display purpose)
  979.     SHGDN_INFOLDER          = 1,        // displayed under a folder (relative)
  980.     SHGDN_FORPARSING        = 0x8000,   // for ParseDisplayName or path
  981. } SHGNO;
  982.  
  983. // IShellFolder::EnumObjects
  984. typedef enum tagSHCONTF
  985. {
  986.     SHCONTF_FOLDERS         = 32,    // for shell browser
  987.     SHCONTF_NONFOLDERS      = 64,    // for default view
  988.     SHCONTF_INCLUDEHIDDEN   = 128,    // for hidden/system objects
  989. } SHCONTF;
  990.  
  991. // IShellFolder::GetAttributesOf flags
  992. #define SFGAO_CANCOPY           DROPEFFECT_COPY // Objects can be copied
  993. #define SFGAO_CANMOVE           DROPEFFECT_MOVE // Objects can be moved
  994. #define SFGAO_CANLINK           DROPEFFECT_LINK // Objects can be linked
  995. #define SFGAO_CANRENAME         0x00000010L     // Objects can be renamed
  996. #define SFGAO_CANDELETE         0x00000020L     // Objects can be deleted
  997. #define SFGAO_HASPROPSHEET      0x00000040L     // Objects have property sheets
  998. #define SFGAO_DROPTARGET    0x00000100L    // Objects are drop target
  999. #define SFGAO_CAPABILITYMASK    0x00000177L
  1000. #define SFGAO_LINK              0x00010000L     // Shortcut (link)
  1001. #define SFGAO_SHARE             0x00020000L     // shared
  1002. #define SFGAO_READONLY          0x00040000L     // read-only
  1003. #define SFGAO_GHOSTED           0x00080000L     // ghosted icon
  1004. #define SFGAO_DISPLAYATTRMASK   0x000F0000L
  1005. #define SFGAO_FILESYSANCESTOR   0x10000000L     // It contains file system folder
  1006. #define SFGAO_FOLDER            0x20000000L     // It's a folder.
  1007. #define SFGAO_FILESYSTEM        0x40000000L     // is a file system thing (file/folder/root)
  1008. #define SFGAO_HASSUBFOLDER      0x80000000L     // Expandable in the map pane
  1009. #define SFGAO_CONTENTSMASK      0x80000000L
  1010. #define SFGAO_VALIDATE          0x01000000L     // invalidate cached information
  1011. #define SFGAO_REMOVABLE        0x02000000L     // is this removeable media?
  1012.  
  1013. DECLARE_INTERFACE_(IShellFolder, IUnknown)
  1014. {
  1015.     // *** IUnknown methods ***
  1016.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  1017.     STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
  1018.     STDMETHOD_(ULONG,Release) (THIS) PURE;
  1019.  
  1020.     // *** IShellFolder methods ***
  1021.     STDMETHOD(ParseDisplayName) (THIS_ HWND hwndOwner,
  1022.     LPBC pbcReserved, LPOLESTR lpszDisplayName,
  1023.         ULONG * pchEaten, LPITEMIDLIST * ppidl, ULONG *pdwAttributes) PURE;
  1024.  
  1025.     STDMETHOD(EnumObjects) ( THIS_ HWND hwndOwner, DWORD grfFlags, LPENUMIDLIST * ppenumIDList) PURE;
  1026.  
  1027.     STDMETHOD(BindToObject)     (THIS_ LPCITEMIDLIST pidl, LPBC pbcReserved,
  1028.                  REFIID riid, LPVOID * ppvOut) PURE;
  1029.     STDMETHOD(BindToStorage)    (THIS_ LPCITEMIDLIST pidl, LPBC pbcReserved,
  1030.                  REFIID riid, LPVOID * ppvObj) PURE;
  1031.     STDMETHOD(CompareIDs)       (THIS_ LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) PURE;
  1032.     STDMETHOD(CreateViewObject) (THIS_ HWND hwndOwner, REFIID riid, LPVOID * ppvOut) PURE;
  1033.     STDMETHOD(GetAttributesOf)  (THIS_ UINT cidl, LPCITEMIDLIST * apidl,
  1034.                     ULONG * rgfInOut) PURE;
  1035.     STDMETHOD(GetUIObjectOf)    (THIS_ HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl,
  1036.                          REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) PURE;
  1037.     STDMETHOD(GetDisplayNameOf) (THIS_ LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName) PURE;
  1038.     STDMETHOD(SetNameOf)        (THIS_ HWND hwndOwner, LPCITEMIDLIST pidl,
  1039.                  LPCOLESTR lpszName, DWORD uFlags,
  1040.                  LPITEMIDLIST * ppidlOut) PURE;
  1041. };
  1042.  
  1043. typedef IShellFolder * LPSHELLFOLDER;
  1044.  
  1045. //
  1046. //  Helper function which returns a IShellFolder interface to the desktop
  1047. // folder. This is equivalent to call CoCreateInstance with CLSID_ShellDesktop.
  1048. //
  1049. //  CoCreateInstance(CLSID_Desktop, NULL,
  1050. //                   CLSCTX_INPROC, IID_IShellFolder, &pshf);
  1051. //
  1052. WINSHELLAPI HRESULT WINAPI SHGetDesktopFolder(LPSHELLFOLDER *ppshf);
  1053.  
  1054. //==========================================================================
  1055. // Clipboard format which may be supported by IDataObject from system
  1056. // defined shell folders (such as directories, network, ...).
  1057. //==========================================================================
  1058.  
  1059. #define CFSTR_SHELLIDLIST       "Shell IDList Array"    // CF_IDLIST
  1060. #define CFSTR_SHELLIDLISTOFFSET "Shell Object Offsets"    // CF_OBJECTPOSITIONS
  1061. #define CFSTR_NETRESOURCES      "Net Resource"        // CF_NETRESOURCE
  1062. #define CFSTR_FILEDESCRIPTOR     "FileGroupDescriptor"    // CF_FILEGROUPDESCRIPTOR
  1063. #define CFSTR_FILECONTENTS     "FileContents"        // CF_FILECONTENTS
  1064. #define CFSTR_FILENAME           "FileName"        // CF_FILENAME
  1065. #define CFSTR_PRINTERGROUP    "PrinterFriendlyName"   // CF_PRINTERS
  1066. #define CFSTR_FILENAMEMAP    "FileNameMap"        // CF_FILENAMEMAP
  1067.  
  1068. //
  1069. // CF_OBJECTPOSITIONS
  1070. //
  1071. //
  1072.  
  1073. #define DVASPECT_SHORTNAME    2 // use for CF_HDROP to get short name version
  1074. //
  1075. // format of CF_NETRESOURCE
  1076. //
  1077. typedef struct _NRESARRAY {    // anr
  1078.     UINT cItems;
  1079.     NETRESOURCE    nr[1];
  1080. } NRESARRAY, * LPNRESARRAY;
  1081.  
  1082. //
  1083. // format of CF_IDLIST
  1084. //
  1085. typedef struct _IDA {
  1086.     UINT cidl;        // number of relative IDList
  1087.     UINT aoffset[1];    // [0]: folder IDList, [1]-[cidl]: item IDList
  1088. } CIDA, * LPIDA;
  1089.  
  1090. //
  1091. // FILEDESCRIPTOR.dwFlags field indicate which fields are to be used
  1092. //
  1093. typedef enum {
  1094.     FD_CLSID        = 0x0001,
  1095.     FD_SIZEPOINT    = 0x0002,
  1096.     FD_ATTRIBUTES       = 0x0004,
  1097.     FD_CREATETIME       = 0x0008,
  1098.     FD_ACCESSTIME       = 0x0010,
  1099.     FD_WRITESTIME       = 0x0020,
  1100.     FD_FILESIZE        = 0x0040,
  1101.     FD_LINKUI        = 0x8000,    // 'link' UI is prefered
  1102. } FD_FLAGS;
  1103.  
  1104. typedef struct _FILEDESCRIPTOR { // fod
  1105.     DWORD dwFlags;
  1106.  
  1107.     CLSID clsid;
  1108.     SIZEL sizel;
  1109.     POINTL pointl;
  1110.  
  1111.     DWORD dwFileAttributes;
  1112.     FILETIME ftCreationTime;
  1113.     FILETIME ftLastAccessTime;
  1114.     FILETIME ftLastWriteTime;
  1115.     DWORD nFileSizeHigh;
  1116.     DWORD nFileSizeLow;
  1117.     CHAR   cFileName[ MAX_PATH ];
  1118. } FILEDESCRIPTOR, *LPFILEDESCRIPTOR;
  1119.  
  1120. //
  1121. // format of CF_FILEGROUPDESCRIPTOR
  1122. //
  1123. typedef struct _FILEGROUPDESCRIPTOR { // fgd
  1124.      UINT cItems;
  1125.      FILEDESCRIPTOR fgd[1];
  1126. } FILEGROUPDESCRIPTOR, * LPFILEGROUPDESCRIPTOR;
  1127.  
  1128. //
  1129. // format of CF_HDROP and CF_PRINTERS, in the HDROP case the data that follows
  1130. // is a double null terinated list of file names, for printers they are printer
  1131. // friendly names
  1132. //
  1133. typedef struct _DROPFILES {
  1134.    DWORD pFiles;                       // offset of file list
  1135.    POINT pt;                           // drop point (client coords)
  1136.    BOOL fNC;                           // is it on NonClient area
  1137.                        // and pt is in screen coords
  1138.    BOOL fWide;                         // WIDE character switch
  1139. } DROPFILES, FAR * LPDROPFILES;
  1140.  
  1141. //====== File System Notification APIs ===============================
  1142. //
  1143.  
  1144. //
  1145. //  File System Notification flags
  1146. //
  1147.  
  1148. #define SHCNE_RENAMEITEM          0x00000001L
  1149. #define SHCNE_CREATE              0x00000002L
  1150. #define SHCNE_DELETE              0x00000004L
  1151. #define SHCNE_MKDIR              0x00000008L
  1152. #define SHCNE_RMDIR               0x00000010L
  1153. #define SHCNE_MEDIAINSERTED       0x00000020L
  1154. #define SHCNE_MEDIAREMOVED        0x00000040L
  1155. #define SHCNE_DRIVEREMOVED        0x00000080L
  1156. #define SHCNE_DRIVEADD            0x00000100L
  1157. #define SHCNE_NETSHARE            0x00000200L
  1158. #define SHCNE_NETUNSHARE          0x00000400L
  1159. #define SHCNE_ATTRIBUTES          0x00000800L
  1160. #define SHCNE_UPDATEDIR           0x00001000L
  1161. #define SHCNE_UPDATEITEM          0x00002000L
  1162. #define SHCNE_SERVERDISCONNECT    0x00004000L
  1163. #define SHCNE_UPDATEIMAGE         0x00008000L
  1164. #define SHCNE_DRIVEADDGUI         0x00010000L
  1165. #define SHCNE_RENAMEFOLDER        0x00020000L
  1166. #define SHCNE_FREESPACE           0x00040000L
  1167.  
  1168. #define SHCNE_ASSOCCHANGED        0x08000000L
  1169.  
  1170. #define SHCNE_DISKEVENTS          0x0002381FL
  1171. #define SHCNE_GLOBALEVENTS        0x0C0581E0L // Events that dont match pidls first
  1172. #define SHCNE_ALLEVENTS           0x7FFFFFFFL
  1173. #define SHCNE_INTERRUPT           0x80000000L // The presence of this flag indicates
  1174.                                             // that the event was generated by an
  1175.                                             // interrupt.  It is stripped out before
  1176.                                             // the clients of SHCNNotify_ see it.
  1177.  
  1178. // Flags
  1179. // uFlags & SHCNF_TYPE is an ID which indicates what dwItem1 and dwItem2 mean
  1180. #define SHCNF_IDLIST      0x0000    // LPITEMIDLIST
  1181. #define SHCNF_PATH        0x0001    // path name
  1182. #define SHCNF_PRINTER     0x0002    // printer friendly name
  1183. #define SHCNF_DWORD       0x0003    // DWORD
  1184. #define SHCNF_TYPE        0x00FF
  1185. #define SHCNF_FLUSH       0x1000
  1186. #define SHCNF_FLUSHNOWAIT 0x2000
  1187.  
  1188. //
  1189. //  APIs
  1190. //
  1191. WINSHELLAPI void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags,
  1192.                 LPCVOID dwItem1, LPCVOID dwItem2);
  1193.  
  1194. //
  1195. // SHAddToRecentDocs
  1196. //
  1197. #define SHARD_PIDL    0x00000001L
  1198. #define SHARD_PATH      0x00000002L
  1199.  
  1200. WINSHELLAPI void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv);
  1201.  
  1202. WINSHELLAPI HRESULT WINAPI SHGetInstanceExplorer(IUnknown **ppunk);
  1203.  
  1204. #ifdef __cplusplus
  1205. }
  1206.  
  1207. #endif  /* __cplusplus */
  1208.  
  1209. #ifndef RC_INVOKED
  1210. #pragma pack()
  1211. #endif  /* !RC_INVOKED */
  1212.  
  1213. #endif // _SHLOBJ_H_
  1214.