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