shellprv.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 33k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #ifndef _SHELLPRV_H_
  2. #define _SHELLPRV_H_
  3. #define OVERRIDE_SHLWAPI_PATH_FUNCTIONS     // see comment in shsemip.h
  4. #define _WIN32_DCOM     // for COINIT_DISABLE_OLE1DDE
  5. #define _OLE32_         // for DECLSPEC_IMPORT delay load
  6. #define _SHELL32_       // for DECLSPEC_IMPORT
  7. #define _FSMENU_        // for DECLSPEC_IMPORT
  8. #define _BROWSEUI_      // Make functions exported from browseui as stdapi (as they are delay loaded)
  9. #define _USERENV_
  10. //
  11. // Enable channels for the IE4 upgrades.
  12. //
  13. #define ENABLE_CHANNELS
  14. #ifdef __cplusplus
  15. #define NO_INCLUDE_UNION
  16. #endif  /* __cplusplus */
  17. #define NOWINDOWSX
  18. #define STRICT
  19. #define OEMRESOURCE // FSMenu needs the menu triangle
  20. #define INC_OLE2
  21. #define CONST_VTABLE
  22. #ifdef WINNT
  23. //
  24. // Disable a few warnings so we can include the system header files at /W4.
  25. //
  26. #include "warning.h"
  27. //
  28. //  These NT headers must come before <windows.h> or you get redefinition
  29. //  errors!  It's a miracle the system builds at all...
  30. //
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif  /* __cplusplus */
  34. #include <nt.h>         // Some of the NT specific code needs Rtl functions
  35. #include <ntrtl.h>      // which requires all of these header files...
  36. #include <nturtl.h>
  37. #include <ntdddfs.h>
  38. #include <ntseapi.h>
  39. #ifdef __cplusplus
  40. }       /* End of extern "C" */
  41. #endif  /* __cplusplus */
  42. #endif // WINNT
  43. #define CC_INTERNAL   // this is because docfind uses the commctrl internal prop sheet structures
  44. // This stuff must run on Win95
  45. #ifndef WINVER
  46. #define WINVER              0x0400
  47. #endif
  48. // And this stuff must run on NT4 (except for apithk.c)
  49. #ifndef _WIN32_WINNT
  50. #define _WIN32_WINNT 0x0400
  51. #endif
  52. // For dllload: change function prototypes to not specify declspec import
  53. #define _OLEAUT32_
  54. #define _SHDOCVW_
  55. #define _LINKINFO_
  56. //--------------------------------------------------------------------------
  57. //
  58. //  The order of these is critical for ATL.
  59. //
  60. //  1.  ATL has its own definition of InlineIsEqualGUID that conflicts with
  61. //      the definition in <objbase.h>, so we must explicitly include
  62. //      <ole2.h> to get the <objbase.h> definition, then use a hacky macro
  63. //      to disable the ATL version so it doesn't conflict with the OLE one.
  64. //
  65. //  2.  ATL has methods called SubclassWindow, which conflicts with a
  66. //      macro in <windowsx.h>, so we must include <windowsx.h> after ATL.
  67. //
  68. //  3.  We want ATL to use the shell debug macros, so we must include
  69. //      <debug.h> before ATL so it can see the shell debug macros.
  70. //
  71. //  4.  VariantInit is such a trivial function that we inline it in order
  72. //      to avoid pulling in OleAut32.
  73. //
  74. //  5.  We want ATL to use the shell version of the ANSI/UNICODE conversion
  75. //      functions (because the shell versions can be called from C).
  76. //
  77. #include <windows.h>
  78. #include <ole2.h>           // Get the real InlineIsEqualGUID
  79. #define _ATL_NO_DEBUG_CRT   // Use the shell debug macros
  80. #include <debug.h>          // Get the shell debug macros
  81. #include <shconv.h>         // Shell version of <atlconv.h>
  82. #define VariantInit(p) memset(p, 0, sizeof(*(p)))
  83. #ifdef __cplusplus
  84. #define _ATL_APARTMENT_THREADED
  85. #ifndef _SYS_GUID_OPERATORS_
  86. // Re-route the ATL version of InlineIsEqualGUID
  87. #define InlineIsEqualGUID ATL_InlineIsEqualGUID
  88. #endif
  89. #include <atlbase.h>
  90. //You may derive a class from CComModule and use it if you want to override
  91. //something, but do not change the name of _Module
  92. extern CComModule _Module;
  93. #include <atlcom.h>
  94. #include <atlctl.h>
  95. #include <atliface.h>
  96. #include <atlwin.h>
  97. #ifndef _SYS_GUID_OPERATORS_
  98. #undef InlineIsEqualGUID    // Return InlineIsEqualGUID to its normal state
  99. #endif
  100. #endif  /* __cplusplus */
  101. // end of ATL Stuff
  102. //--------------------------------------------------------------------------
  103. #ifndef _SYS_GUID_OPERATORS_
  104. #ifdef _OLE32_ // {
  105. // turning on _OLE32_ (which we did for delay load stuff) gives us f-a-t
  106. // versions of IsEqualGUID.  undo that here (hack on top of a hack...)
  107. #undef IsEqualGUID
  108. #ifdef __cplusplus
  109. __inline BOOL IsEqualGUID(IN REFGUID rguid1, IN REFGUID rguid2)
  110. {
  111.     return !memcmp(&rguid1, &rguid2, sizeof(GUID));
  112. }
  113. #else   //  ! __cplusplus
  114. #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
  115. #endif  //  __cplusplus
  116. #endif // }
  117. #endif
  118. #ifdef __cplusplus
  119. extern "C" {            /* Assume C declarations for C++ */
  120. #endif  /* __cplusplus */
  121. // This flag indicates that we are on a system where data alignment is a concern
  122. #if (defined(UNICODE) && (defined(_MIPS_) || defined(_ALPHA_) || defined(_PPC_)))
  123. #define ALIGNMENT_SCENARIO
  124. #endif
  125. #include <windowsx.h>
  126. #ifdef WINNT_ENV
  127. #include <winnetp.h>
  128. #endif
  129. #ifndef WINNT
  130. //
  131. //  Win95 doesn't have BroadcastSystemMessageA/W; it just has the plain
  132. //  version.
  133. //
  134. #undef BroadcastSystemMessage
  135. WINAPI BroadcastSystemMessage(DWORD, LPDWORD, UINT, WPARAM, LPARAM);
  136. #endif
  137. //
  138. //  Dependencies among header files:
  139. //
  140. //      <oaidl.h> must come before <shlwapi.h> if you want to have
  141. //      OLE command target helper functions.
  142. //
  143. #include <hlink.h> // must include before shellp in order to get IBrowserService2!
  144. #include <commctrl.h>
  145. #include <shellapi.h>
  146. #include <wininet.h>
  147. #include <shlobj.h>
  148. #include <shlwapi.h>
  149. #include <commdlg.h>
  150. #include <port32.h>         // in    shellinc
  151. #define DISALLOW_Assert
  152. #include <linkinfo.h>
  153. #include <shlobjp.h>
  154. #include <shsemip.h>
  155. #include <docobj.h>
  156. #include <shguidp.h>
  157. #include <shellp.h>
  158. #include <shldispp.h>
  159. #include <shdocvw.h>
  160. #include <iethread.h>
  161. #include "browseui.h"
  162. #include <ccstock.h>
  163. #include <ccstock2.h>
  164. #include <msi.h>
  165. #include <objidl.h>
  166. #include "apithk.h"
  167. #define SECURITY_WIN32
  168. #include <security.h>
  169. #include <mlang.h>
  170. #include <krnlcmn.h>    // GetProcessDword
  171. #ifndef NO_MULTIMON
  172. #include "multimon.h"   // for multiple-monitor APIs on pre-Nashville systems
  173. #endif // NO_MULTIMON
  174. #include <heapaloc.h>
  175. #ifdef WINNT
  176. #include <fmifs.h>
  177. #endif // WINNT
  178. #ifdef PW2
  179. #include <penwin.h>
  180. #endif //PW2
  181. #include "util.h"
  182. #include "cstrings.h"
  183. #include "securent.h"
  184. #ifdef WINNT
  185. #include "winprtp.h"
  186. #endif
  187. #include "dllload.h"
  188. #include "../lib/qistub.h"
  189. #ifdef DEBUG
  190. #include "../lib/dbutil.h"
  191. #endif
  192. #ifndef WINNT
  193. //
  194. // Don't use functions that aren't implemented on Win9x
  195. //
  196. #define lstrcatW       Do_not_use_lstrcatW_use_StrCatBuffW
  197. #define wsprintfW      Do_not_use_wsprintfW_use_wnsprintfW
  198. #define lstrncmpiW     Do_not_use_lstrncmpiW_use_StrCmpNIW
  199. #endif
  200. #define CP_HEBREW        1255
  201. #define CP_ARABIC        1256
  202. #define CODESEG
  203. EXTERN_C const UNALIGNED ITEMIDLIST c_idlDesktop;   // NULL IDList
  204. #if !defined(DBCS) || defined(WINNT)
  205. // NB - These are already macros in Win32 land.
  206. #undef CharNext
  207. #undef CharPrev
  208. #define CharNext(x) ((x)+1)
  209. #define CharPrev(y,x) ((x)-1)
  210. #define IsDBCSLeadByte(x) ((x), FALSE)
  211. #endif // !defined(DBCS) || defined(WINNT)
  212. #ifdef WINNT
  213. // nothunk.c
  214. //
  215. // Until we figure out what we want to do with these functions,
  216. // define them to an internal name so that we don't cause the
  217. // linker to spew at us
  218. #undef ReinitializeCriticalSection
  219. #undef LoadLibrary16
  220. #undef FreeLibrary16
  221. #undef GetProcAddress16
  222. #define ReinitializeCriticalSection NoThkReinitializeCriticalSection
  223. #define LoadLibrary16 NoThkLoadLibrary16
  224. #define FreeLibrary16 NoThkFreeLibrary16
  225. #define GetProcAddress16 NoThkGetProcAddress16
  226. #define GetModuleHandle16 NoThkGetModuleHandle16
  227. VOID WINAPI NoThkReinitializeCriticalSection(
  228.     LPCRITICAL_SECTION lpCriticalSection
  229.     );
  230. HINSTANCE WINAPI NoThkLoadLibrary16(
  231.     LPCTSTR lpLibFileName
  232.     );
  233. BOOL WINAPI NoThkFreeLibrary16(
  234.     HINSTANCE hLibModule
  235.     );
  236. FARPROC WINAPI NoThkGetProcAddress16(
  237.     HINSTANCE hModule,
  238.     LPCSTR lpProcName
  239.     );
  240. DWORD
  241. SetPrivilegeAttribute(
  242.     IN  LPCTSTR PrivilegeName,
  243.     IN  DWORD   NewPrivilegeAttributes,
  244.     OUT DWORD   *OldPrivilegeAttribute
  245.     );
  246. #endif // WINNT
  247. #ifdef WINDOWS_ME
  248. //
  249. // This is needed for BiDi localized win95 RTL stuff
  250. //
  251. extern BOOL g_bBiDiW95Loc;
  252. #else // !WINDOWS_ME
  253. #define g_bBiDiW95Loc FALSE
  254. #endif // WINDOWS_ME
  255. // defcm.c
  256. STDAPI CDefFolderMenu_CreateHKeyMenu(HWND hwndOwner, HKEY hkey, IContextMenu **ppcm);
  257. STDAPI CDefFolderMenu_Create2Ex(LPCITEMIDLIST pidlFolder, HWND hwnd,
  258.                                 UINT cidl, LPCITEMIDLIST *apidl,
  259.                                 IShellFolder *psf, IContextMenuCB *pcmcb, 
  260.                                 UINT nKeys, const HKEY *ahkeyClsKeys, 
  261.                                 IContextMenu **ppcm);
  262. STDAPI CDefFolderMenu_CreateEx(LPCITEMIDLIST pidlFolder,
  263.                              HWND hwnd, UINT cidl, LPCITEMIDLIST *apidl,
  264.                              IShellFolder *psf, IContextMenuCB *pcmcb, 
  265.                              HKEY hkeyProgID, HKEY hkeyBaseProgID,
  266.                              IContextMenu **ppcm);
  267. // drivesx.c
  268. BOOL IsUnavailableNetDrive(int iDrive);
  269. BOOL IsDisconnectedNetDrive(int iDrive);
  270. BOOL IsAudioDisc(LPTSTR pszDrive);
  271. BOOL IsDVDDisc(int iDrive);
  272. // futil.c
  273. BOOL  IsShared(LPNCTSTR pszPath, BOOL fUpdateCache);
  274. DWORD GetConnection(LPCTSTR lpDev, LPTSTR lpPath, UINT cbPath, BOOL bConvertClosed);
  275. // rundll32.c
  276. HWND _CreateStubWindow(POINT* ppt, HWND hwndParent);
  277. #define STUBM_SETDATA       (WM_USER)
  278. #define STUBM_GETDATA       (WM_USER + 1)
  279. #define STUBM_SETICONTITLE  (WM_USER + 2)
  280. #define STUBCLASS_PROPSHEET     1
  281. #define STUBCLASS_FORMAT        2
  282. // shlexe.c
  283. BOOL IsDarwinEnabled();
  284. STDAPI ParseDarwinID(LPTSTR pszDarwinDescriptor, LPTSTR pszDarwinCommand, DWORD cchDarwinCommand);
  285. // browse.cpp
  286. #define MYDOCS_CLSID TEXT("{450d8fba-ad25-11d0-98a8-0800361b1103}") // CLSID_MyDocuments
  287. STDAPI_(LPITEMIDLIST) MyDocsIDList();
  288. STDAPI GetMyDocumentsDisplayName(LPTSTR pszPath, UINT cch);
  289. // shprsht.c
  290. typedef struct _UNIQUESTUBINFO {
  291.     HWND    hwndStub;
  292.     HANDLE  hClassPidl;
  293.     HICON   hicoStub;
  294. } UNIQUESTUBINFO;
  295. STDAPI_(BOOL) EnsureUniqueStub(LPITEMIDLIST pidl, int iClass, POINT *ppt, UNIQUESTUBINFO *pusi);
  296. STDAPI_(void) FreeUniqueStub(UNIQUESTUBINFO *pusi);
  297. STDAPI_(void) SHFormatDriveAsync(HWND hwnd, UINT drive, UINT fmtID, UINT options);
  298. // bitbuck.c
  299. void  RelayMessageToChildren(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
  300. BOOL IsFileInBitBucket(LPCTSTR pszPath);
  301. BOOL CreateWriteCloseFile(HWND hwnd, LPCTSTR pszFileName, void *pv, DWORD cbData);
  302. // idlist.c
  303. STDAPI_(BOOL) SHIsValidPidl(LPCITEMIDLIST pidl);
  304. #ifdef WINNT
  305. // os.c
  306. STDAPI_(BOOL) IsExeTSAware(LPCTSTR pszExe);
  307. #endif // WINNT
  308. // exec stuff
  309. /* common exe code with error handling */
  310. #define SECL_USEFULLPATHDIR     0x00000001
  311. #define SECL_NO_UI              0x00000002
  312. #define SECL_SEPARATE_VDM   0x00000002
  313. BOOL ShellExecCmdLine(HWND hwnd, LPCTSTR lpszCommand, LPCTSTR lpszDir,
  314.         int nShow, LPCTSTR lpszTitle, DWORD dwFlags);
  315. #define ISSHELLEXECSUCCEEDED(hinst) ((UINT_PTR)hinst>32)
  316. #define ISWINEXECSUCCEEDED(hinst)   ((UINT_PTR)hinst>=32)
  317. void _ShellExecuteError(LPSHELLEXECUTEINFO pei, LPCTSTR lpTitle, DWORD dwErr);
  318. // fsnotify.c (private stuff) ----------------------
  319. BOOL SHChangeNotifyInit();
  320. void SHChangeNotifyTerminate(BOOL);
  321. void SHChangeNotifyReceiveEx(LONG lEvent, UINT uFlags, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlExtra, DWORD dwEventTime);
  322. LRESULT SHChangeNotify_OnNotify(WPARAM wParam, LPARAM lParam);
  323. LRESULT SHChangeNotify_OnChangeRegistration(WPARAM wParam, LPARAM lParam);
  324. LRESULT SHChangeNotify_OnNotifySuspendResume(WPARAM wParam, LPARAM lParam);
  325. LRESULT SHChangeNotify_OnDeviceChange(ULONG_PTR code, struct _DEV_BROADCAST_HDR *pbh);
  326. void    SHChangeNotify_DesktopInit();
  327. void    SHChangeNotify_DesktopTerm();
  328. void _Shell32ThreadAddRef(BOOL fLeaveSuspended);
  329. void _Shell32ThreadRelease(UINT nClients);
  330. void _Shell32ThreadAwake(void);
  331. // Entry points for managing registering name to IDList translations.
  332. void NPTRegisterNameToPidlTranslation(LPCTSTR pszPath, LPCITEMIDLIST pidl);
  333. LPCTSTR NPTMapNameToPidl(LPCTSTR pszPath, LPCITEMIDLIST *ppidl);
  334. HKEY SHGetExplorerHkey(HKEY hkeyRoot, BOOL bCreate);
  335. HKEY SHGetExplorerSubHkey(HKEY hkRoot, LPCTSTR szSubKey, BOOL bCreate);
  336. // path.c (private stuff) ---------------------
  337. #define PQD_NOSTRIPDOTS 0x00000001
  338. STDAPI_(void) PathQualifyDef(LPTSTR psz, LPCTSTR szDefDir, DWORD dwFlags);
  339. STDAPI_(BOOL) PathIsRemovable(LPCTSTR pszPath);
  340. STDAPI_(BOOL) PathIsTemporary(LPCTSTR pszPath);
  341. STDAPI_(BOOL) PathIsWild(LPCTSTR pszPath);
  342. STDAPI_(BOOL) PathIsLnk(LPCTSTR pszFile);
  343. STDAPI_(BOOL) PathIsSlow(LPCTSTR pszFile, DWORD dwFileAttr);
  344. STDAPI_(BOOL) PathIsHighLatency(LPCTSTR pszFile, DWORD dwFileAttr);
  345. STDAPI_(BOOL) PathIsInvalid(LPCTSTR pPath);
  346. STDAPI_(BOOL) PathIsBinaryExe(LPCTSTR szFile);
  347. STDAPI_(BOOL) PathMergePathName(LPTSTR pPath, LPCTSTR pName);
  348. STDAPI_(BOOL) PathGetMountPointFromPath(LPCTSTR pcszPath, LPTSTR pszMountPoint, int cchMountPoint);
  349. STDAPI_(BOOL) PathIsShortcutToProgram(LPCTSTR pszFile);
  350. STDAPI_(BOOL) NetPathExists(LPCTSTR lpszPath, DWORD *pdwType);
  351. #if (defined(UNICODE) && (defined(_MIPS_) || defined(_ALPHA_) || defined(_PPC_)))
  352. #else
  353. #define uaPathFindExtension PathFindExtension
  354. #endif
  355. void SpecialFolderIDTerminate();
  356. void ReleaseRootFolders();
  357. extern HINSTANCE g_hinst;
  358. // get the desktop HWND if it is this process...
  359. HWND GetInProcDesktop();
  360. #ifdef WINNT
  361. extern BOOL g_bRunOnNT5;
  362. #define g_bRunOnMemphis     FALSE
  363. #else
  364. extern BOOL g_bRunOnMemphis;
  365. #define g_bRunOnNT5         FALSE
  366. #endif
  367. //
  368. // Is Mirroring APIs enabled (BiDi Memphis and NT5 only)
  369. //
  370. extern BOOL g_bMirroredOS;
  371. //
  372. // Is DATE_LTRREADING supported by GetDateFormat() API?  (it is supported in all the BiDi platforms.)
  373. //
  374. extern BOOL g_bBiDiPlatform;
  375. //
  376. // NOTE these are the size of the icons in our ImageList, not the system
  377. // icon size.
  378. //
  379. extern int g_cxIcon, g_cyIcon;
  380. extern int g_cxSmIcon, g_cySmIcon;
  381. extern HIMAGELIST g_himlIcons;
  382. extern HIMAGELIST g_himlIconsSmall;
  383. // for control panel and printers folder:
  384. extern TCHAR const c_szNull[];
  385. extern TCHAR const c_szDotDot[];
  386. extern TCHAR const c_szRunDll[];
  387. extern TCHAR const c_szNewObject[];
  388. // lang platform
  389. extern UINT g_uCodePage;
  390. // other stuff
  391. #define HINST_THISDLL   g_hinst
  392. //
  393. // Trace/dump/break flags specific to shell32.
  394. //   (Standard flags defined in shellp.h)
  395. //
  396. // Trace flags
  397. #define TF_IMAGE            0x00000010      // Image/icon related stuff
  398. #define TF_PROPERTY         0x00000020      // Property traces
  399. #define TF_PATH             0x00000040      // Path whacking traces
  400. #define TF_MENU             0x00000080      // Menu stuff
  401. #define TF_ALLOC            0x00000100      // Allocation traces
  402. #define TF_REG              0x00000200      // Registry traces
  403. #define TF_DDE              0x00000400      // Shell progman DDE message tracing
  404. #define TF_HASH             0x00000800      // Hash table stuff
  405. #define TF_ASSOC            0x00001000      // File/URL Association traces
  406. #define TF_FILETYPE         0x00002000      // File Type stuff
  407. #define TF_SHELLEXEC        0x00004000      // ShellExecute stuff
  408. #define TF_OLE              0x00008000      // OLE-specific stuff
  409. #define TF_DEFVIEW          0x00010000      // Defview
  410. #define TF_PERF             0x00020000      // Performance timings
  411. #define TF_FSNOTIFY         0x00040000      // FSNotify stuff
  412. #define TF_LIFE             0x00080000      // Object lifetime traces
  413. #define TF_IDLIST           0x00100000      // "PIDLy" things
  414. #define TF_FSTREE           0x00200000      // FSTree traces
  415. #define TF_PRINTER          0x00400000      // Printer traces
  416. //#define TF_QISTUB          0x00800000      // defined in unicppshellprv.h
  417. #define TF_DOCFIND          0x01000000      // DocFind
  418. #define TF_CUSTOM1          0x40000000      // Custom messages #1
  419. #define TF_CUSTOM2          0x80000000      // Custom messages #2
  420. // "Olde names"
  421. #define DM_ALLOC            TF_ALLOC
  422. #define DM_REG              TF_REG
  423. // Function trace flags
  424. #define FTF_DEFVIEW         0x00000004      // DefView calls
  425. #define FTF_DDE             0x00000008      // DDE functions
  426. // Dump flags
  427. #define DF_INTSHCUT         0x00000001      // Internet shortcut structures
  428. #define DF_HASH             0x00000002      // Hash table
  429. #define DF_FSNPIDL          0x00000004      // Pidl for FSNotify
  430. #define DF_URLPROP          0x00000008      // URL property structures
  431. #define DF_DEBUGQI          0x00000010
  432. #define DF_DEBUGQINOREF     0x00000020
  433. #define DF_ICONCACHE        0x00000040      // Icon cache
  434. #define DF_CLASSFLAGS       0x00000080      // File class cache
  435. #define DF_DELAYLOADDLL     0x00000100      // Delay load
  436. // Break flags
  437. #define BF_ONLOADED         0x00000010      // Stop when loaded
  438. #define BF_COCREATEINSTANCE 0x10000000      // On CoCreateInstance failure
  439. // Debugging strings
  440. #define GEN_DEBUGSTRW(str)  ((str) ? (str) : L"<Null Str>")
  441. #define GEN_DEBUGSTRA(str)  ((str) ? (str) : "<Null Str>")
  442. #ifdef UNICODE
  443. #define GEN_DEBUGSTR  GEN_DEBUGSTRW
  444. #else // UNICODE
  445. #define GEN_DEBUGSTR  GEN_DEBUGSTRA
  446. #endif // UNICODE
  447. // Note:  raymondc - ATOMICRELEASE isn't particularly atomic.  There is a race
  448. // condition if two people try to ATOMICRELEASE the same thing simultaneously.
  449. // shorthand
  450. #ifndef ATOMICRELEASE
  451. #ifdef __cplusplus
  452. #define ATOMICRELEASET(p, type) { if(p) { type* punkT=p; p=NULL; punkT->Release();} }
  453. #else
  454. #define ATOMICRELEASET(p, type) { if(p) { type* punkT=p; p=NULL; punkT->lpVtbl->Release(punkT);} }
  455. #endif
  456. // doing this as a function instead of inline seems to be a size win.
  457. //
  458. #ifdef NOATOMICRELESEFUNC
  459. #define ATOMICRELEASE(p) ATOMICRELEASET(p, IUnknown)
  460. #else
  461. #define ATOMICRELEASE(p) IUnknown_AtomicRelease((void **)&p)
  462. #endif
  463. #endif //ATOMICRELEASE
  464. #ifdef SAFERELEASE
  465. #undef SAFERELEASE
  466. #endif
  467. #define SAFERELEASE(p) ATOMICRELEASE(p)
  468. // fileicon.c
  469. void    FileIconTerm(void);
  470. #define CCH_KEYMAX      64          // DOC: max size of a reg key (under shellex)
  471. void ReplaceParams(LPTSTR szDst, LPCTSTR szFile);
  472. #ifdef __IPropertyStorage_INTERFACE_DEFINED__
  473. WINSHELLAPI HRESULT SHPropVariantClear(PROPVARIANT * ppropvar);
  474. WINSHELLAPI HRESULT SHFreePropVariantArray(ULONG cel, PROPVARIANT * ppropvar);
  475. WINSHELLAPI HRESULT SHPropVariantCopy(PROPVARIANT * ppropvar, const PROPVARIANT * ppropvarFrom);
  476. #endif
  477. //
  478. // fsassoc.c
  479. //
  480. #define GCD_MUSTHAVEOPENCMD     0x0001
  481. #define GCD_ADDEXETODISPNAME    0x0002  // must be used with GCD_MUSTHAVEOPENCMD
  482. #define GCD_ALLOWPSUDEOCLASSES  0x0004  // .ext type extensions
  483. // Only valid when used with FillListWithClasses
  484. #define GCD_MUSTHAVEEXTASSOC    0x0008  // There must be at least one extension assoc
  485. BOOL GetClassDescription(HKEY hkClasses, LPCTSTR pszClass, LPTSTR szDisplayName, int cbDisplayName, UINT uFlags);
  486. void FillListWithClasses(HWND hwnd, BOOL fComboBox, UINT uFlags);
  487. void DeleteListAttoms(HWND hwnd, BOOL fComboBox);
  488. //
  489. // Registry key handles
  490. //
  491. extern HKEY g_hkcrCLSID;        // Cached HKEY_CLASSES_ROOTCLSID
  492. extern HKEY g_hklmExplorer;     // Cached HKEY_LOCAL_MACHINE...Explorer
  493. #ifdef WINNT
  494. extern HKEY g_hklmApprovedExt;      // For approved shell extensions
  495. #endif
  496. // always zero, see init.c
  497. extern const LARGE_INTEGER g_li0;
  498. extern const ULARGE_INTEGER g_uli0;
  499. // from link.c
  500. BOOL PathSeperateArgs(LPTSTR pszPath, LPTSTR pszArgs);
  501. // from fstree.cpp and drives.cpp
  502. STDAPI SFVCB_OnAddPropertyPages(IN DWORD pv, IN SFVM_PROPPAGE_DATA * ppagedata);
  503. //
  504. // this used to be in shprst.c
  505. //
  506. #define MAX_FILE_PROP_PAGES 32
  507. HKEY NetOpenProviderClass(HDROP);
  508. void OpenNetResourceProperties(HWND, HDROP);
  509. // msgbox.c
  510. // Constructs strings like ShellMessagebox "xxx %1%s yyy %2%s..."
  511. // BUGBUG: convert to use george's new code in setup
  512. LPTSTR WINCAPI ShellConstructMessageString(HINSTANCE hAppInst, LPCTSTR lpcText, ...);
  513. // fileicon.c
  514. int     SHAddIconsToCache(HICON hIcon, HICON hIconSmall, LPCTSTR pszIconPath, int iIconIndex, UINT uIconFlags);
  515. HICON   SimulateDocIcon(HIMAGELIST himl, HICON hIcon, BOOL fSmall);
  516. //  Copy.c
  517. #define SPEED_SLOW  400
  518. DWORD GetPathSpeed(LPCTSTR pszPath);
  519. // shlobjs.c
  520. STDAPI InvokeFolderCommandUsingPidl(LPCMINVOKECOMMANDINFOEX pici,
  521.         LPCTSTR pszPath, LPCITEMIDLIST pidl, HKEY hkClass, ULONG fExecuteFlags);
  522. // mulprsht.c
  523. typedef struct {
  524.     BOOL            bContinue;      // tell thread to stop or mark as done
  525.     ULONGLONG       cbSize;         // total size of all files in folder
  526.     ULONGLONG       cbActualSize;   // total size on disk, taking into account compression and cluster slop
  527.     DWORD           dwClusterSize;  // the size of a cluster
  528.     int             cFiles;         // # files in folder
  529.     int             cFolders;       // # folders in folder
  530.     TCHAR           szPath[MAX_PATH];
  531.     WIN32_FIND_DATA fd;             // for thread stack savings
  532. } FOLDERCONTENTSINFO;
  533. STDAPI_(BOOL) SHEncryptFile(LPCTSTR pszPath, BOOL fEncrypt);
  534. void _FolderSize(LPCTSTR pszDir, FOLDERCONTENTSINFO * pfci);
  535. // wuutil.c
  536. void cdecl SetFolderStatusText(HWND hwndStatus, int iField, UINT ids,...);
  537. #ifdef DEBUG
  538. extern BOOL  g_bInDllEntry;
  539. #undef SendMessage
  540. #define SendMessage  SendMessageD
  541. LRESULT WINAPI SendMessageD(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  542. //
  543. //  The DEBUG build validates that every class we register is in the
  544. //  unregister list so we don't leak classes at unload.
  545. //
  546. #undef RegisterClass
  547. #undef RegisterClassEx
  548. #define RegisterClass       RegisterClassD
  549. #define RegisterClassEx     RegisterClassExD
  550. ATOM WINAPI RegisterClassD(CONST WNDCLASS *lpWndClass);
  551. ATOM WINAPI RegisterClassExD(CONST WNDCLASSEX *lpWndClass);
  552. #endif // DEBUG
  553. #ifdef UNICODE
  554. #define RealRegisterClass   RegisterClassW
  555. #define RealRegisterClassEx RegisterClassExW
  556. #else
  557. #define RealRegisterClass   RegisterClassA
  558. #define RealRegisterClassEx RegisterClassExA
  559. #endif
  560. //
  561. //  In DEBUG, send FindWindow through a wrapper that ensures that the
  562. //  critical section is not taken.  FindWindow sends interthreadmessages,
  563. //  which is not obvious.
  564. //
  565. #ifdef DEBUG
  566. #undef  FindWindow
  567. #undef  FindWindowEx
  568. #define FindWindow              FindWindowD
  569. #define FindWindowEx            FindWindowExD
  570. STDAPI_(HWND) FindWindowD  (LPCTSTR lpClassName, LPCTSTR lpWindowName);
  571. STDAPI_(HWND) FindWindowExD(HWND hwndParent, HWND hwndChildAfter, LPCTSTR lpClassName, LPCTSTR lpWindowName);
  572. #ifdef UNICODE
  573. #define RealFindWindowEx        FindWindowExW
  574. #else
  575. #define RealFindWindowEx        FindWindowExA
  576. #endif // UNICODE
  577. #endif // DEBUG
  578. #ifdef WINNT
  579. // our wrapper for GetCompressedFileSize, which is NT only
  580. STDAPI_(DWORD) SHGetCompressedFileSizeW(LPCWSTR pszFileName, LPDWORD pFileSizeHigh);
  581. #undef GetCompressedFileSize
  582. #define GetCompressedFileSize SHGetCompressedFileSize
  583. #ifdef UNICODE
  584. #define SHGetCompressedFileSize SHGetCompressedFileSizeW
  585. #else
  586. #define SHGetCompressedFileSize #error // not implemented, because its an nt only API
  587. #endif // UNICODE
  588. #endif // WINNT
  589. #define ASSERTDLLENTRY      ASSERT(g_bInDllEntry);
  590. //
  591. // STATIC macro
  592. //
  593. #ifndef STATIC
  594. #ifdef DEBUG
  595. #define STATIC
  596. #else
  597. #define STATIC static
  598. #endif
  599. #endif
  600. //
  601. // Debug helper functions
  602. //
  603. //
  604. // Validation functions
  605. //
  606. BOOL IsValidPSHELLEXECUTEINFO(LPSHELLEXECUTEINFO pei);
  607. #ifdef WINNT
  608. //
  609. // Defining FULL_DEBUG allows us debug memory problems.
  610. //
  611. #if defined(FULL_DEBUG)
  612. #include <deballoc.h>
  613. #endif // defined(FULL_DEBUG)
  614. #endif
  615. #define FillExecInfo(_info, _hwnd, _verb, _file, _params, _dir, _show) 
  616.         (_info).hwnd            = _hwnd;        
  617.         (_info).lpVerb          = _verb;        
  618.         (_info).lpFile          = _file;        
  619.         (_info).lpParameters    = _params;      
  620.         (_info).lpDirectory     = _dir;         
  621.         (_info).nShow           = _show;        
  622.         (_info).fMask           = 0;            
  623.         (_info).cbSize          = SIZEOF(SHELLEXECUTEINFO);
  624. STDAPI_(LONG) SHRegQueryValueA(HKEY hKey, LPCSTR lpSubKey, LPSTR lpValue, LONG *lpcbValue);
  625. STDAPI_(LONG) SHRegQueryValueW(HKEY hKey, LPCWSTR lpSubKey, LPWSTR lpValue, LONG *lpcbValue);
  626. #ifdef UNICODE
  627. #define SHRegQueryValue     SHRegQueryValueW
  628. #else
  629. #define SHRegQueryValue     SHRegQueryValueA
  630. #endif
  631. #ifdef DEBUG
  632. #if 1
  633.     __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  634.     __inline DWORD clock()     {LARGE_INTEGER li; QueryPerformanceCounter(&li);   return li.LowPart;}
  635. #else
  636.     __inline DWORD clockrate() {return 1000;}
  637.     __inline DWORD clock()     {return GetTickCount();}
  638. #endif
  639.     #define TIMEVAR(t)    DWORD t ## T; DWORD t ## N
  640.     #define TIMEIN(t)     t ## T = 0, t ## N = 0
  641.     #define TIMESTART(t)  t ## T -= clock(), t ## N ++
  642.     #define TIMESTOP(t)   t ## T += clock()
  643.     #define TIMEFMT(t)    ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  644.     #define TIMEOUT(t)    if (t ## N) TraceMsg(TF_PERF, #t ": %ld calls, %ld.%03ld sec (%ld.%03ld)", t ## N, TIMEFMT(t ## T), TIMEFMT(t ## T / t ## N))
  645. #else
  646.     #define TIMEVAR(t)
  647.     #define TIMEIN(t)
  648.     #define TIMESTART(t)
  649.     #define TIMESTOP(t)
  650.     #define TIMEFMT(t)
  651.     #define TIMEOUT(t)
  652. #endif
  653. // in extract.c
  654. STDAPI_(DWORD) GetExeType(LPCTSTR pszFile);
  655. STDAPI_(UINT)  ExtractIcons(LPCTSTR szFileName, int nIconIndex, int cxIcon, int cyIcon, HICON *phicon, UINT *piconid, UINT nIcons, UINT flags);
  656. // defxicon.c
  657. STDAPI SHCreateDefExtIconKey(HKEY hkey, LPCTSTR pszModule, int iIcon, int iIconOpen, UINT uFlags, REFIID riid, void **pxiconOut);
  658. STDAPI SHCreateDefExtIcon(LPCTSTR pszModule, int iIcon, int iIconOpen, UINT uFlags, REFIID riid, void **pxiconOut);
  659. STDAPI_(UINT) SHSysErrorMessageBox(HWND hwnd, LPCTSTR pszTitle, UINT idTemplate, DWORD err, LPCTSTR pszParam, UINT dwFlags);
  660. //======Hash Item=============================================================
  661. typedef struct _HashTable * PHASHTABLE;
  662. #define PHASHITEM LPCTSTR
  663. typedef void (CALLBACK *HASHITEMCALLBACK)(PHASHTABLE pht, LPCTSTR sz, UINT wUsage, DWORD param);
  664. STDAPI_(LPCTSTR) FindHashItem  (PHASHTABLE pht, LPCTSTR lpszStr);
  665. STDAPI_(LPCTSTR) AddHashItem   (PHASHTABLE pht, LPCTSTR lpszStr);
  666. STDAPI_(LPCTSTR) DeleteHashItem(PHASHTABLE pht, LPCTSTR lpszStr);
  667. STDAPI_(LPCTSTR) PurgeHashItem (PHASHTABLE pht, LPCTSTR lpszStr);
  668. #define     GetHashItemName(pht, sz, lpsz, cch)  lstrcpyn(lpsz, sz, cch)
  669. PHASHTABLE  WINAPI CreateHashItemTable(UINT wBuckets, UINT wExtra, BOOL fCaseSensitive);
  670. void        WINAPI DestroyHashItemTable(PHASHTABLE pht);
  671. void        WINAPI SetHashItemData(PHASHTABLE pht, LPCTSTR lpszStr, int n, DWORD_PTR dwData);
  672. DWORD_PTR   WINAPI GetHashItemData(PHASHTABLE pht, LPCTSTR lpszStr, int n);
  673. void *      WINAPI GetHashItemDataPtr(PHASHTABLE pht, LPCTSTR lpszStr);
  674. void        WINAPI EnumHashItems(PHASHTABLE pht, HASHITEMCALLBACK callback, DWORD dwParam);
  675. #ifdef DEBUG
  676. void        WINAPI DumpHashItemTable(PHASHTABLE pht);
  677. #endif
  678. //======== Text thunking stuff ===========================================================
  679. #ifdef WINNT
  680. typedef struct _THUNK_TEXT_
  681. {
  682.     LPTSTR m_pStr[1];
  683. } ThunkText;
  684. #ifdef UNICODE
  685.     typedef CHAR        XCHAR;
  686.     typedef LPSTR       LPXSTR;
  687.     typedef const XCHAR * LPCXSTR;
  688.     #define lstrlenX(r) lstrlenA(r)
  689. #else // unicode
  690.     typedef WCHAR       XCHAR;
  691.     typedef LPWSTR      LPXSTR;
  692.     typedef const XCHAR * LPCXSTR;
  693.     #define lstrlenX(r) lstrlenW(r)
  694. #endif // unicode
  695. ThunkText * ConvertStrings(UINT cCount, ...);
  696. #else //
  697. typedef LPSTR LPXSTR;
  698. #define lstrlenX lstrlenA
  699. #endif  // winnt
  700. #include "uastrfnc.h"
  701. #ifdef __cplusplus
  702. }       /* End of extern "C" { */
  703. extern "C" inline __cdecl _purecall(void) {return 0;}
  704. #ifndef _M_PPC
  705. #pragma intrinsic(memcpy)
  706. #pragma intrinsic(memcmp)
  707. #endif
  708. #endif /* __cplusplus */
  709. #include <help.h>
  710. //======== Discriminate inclusion ========================================
  711. #ifndef NO_INCLUDE_UNION        // define this to avoid including all
  712.                                 // of the extra files that were not
  713.                                 // previously included in shellprv.h
  714. #include <wchar.h>
  715. #include <tchar.h>
  716. //
  717. // NT header files
  718. //
  719. #ifdef WINNT
  720. #include <process.h>
  721. #include <wowshlp.h>
  722. #include <vdmapi.h>
  723. #include <shell.h>
  724. #include "dde.h"
  725. #endif
  726. //
  727. // Chicago header files
  728. //
  729. #include <regstr.h>
  730. #include "findhlp.h"
  731. #include <krnlcmn.h>
  732. #include <dlgs.h>
  733. #include <err.h>
  734. #include <msprintx.h>
  735. #include <pif.h>
  736. #include <windisk.h>
  737. #include <brfcasep.h>
  738. #include <trayp.h>
  739. #include <brfcasep.h>
  740. #include <wutilsp.h>
  741. //
  742. // SHELLDLL Specific header files
  743. //
  744. #include "bitbuck.h"
  745. #include "defview.h"
  746. #include "drawpie.h"
  747. #include "fileop.h"
  748. #include "filetbl.h"
  749. #include "pidl.h"
  750. #include "idmk.h"
  751. #include "ids.h"
  752. #include "lvutil.h"
  753. #include <newexe.h>
  754. #include "newres.h"
  755. #include "ole2dup.h"
  756. #include "os.h"
  757. #include "privshl.h"
  758. #include "reglist.h"
  759. #include "shell32p.h"
  760. #include "shitemid.h"
  761. #include "shlgrep.h"
  762. #include "shobjprv.h"
  763. #include "undo.h"
  764. #include "vdate.h"
  765. #include "views.h"
  766. #include "ynlist.h"
  767. #ifdef WINNT
  768. // NT shell uses 32-bit version of this pifmgr code.
  769. #ifndef NO_PIF_HDRS
  770. #include "pifmgrp.h"
  771. #include "piffntp.h"
  772. #include "pifinfp.h"
  773. #include "doshelp.h"
  774. #include "machinep.h"   // Japanese domestic machine (NEC) support
  775. #include "oemhard.h"
  776. #endif
  777. #endif
  778. #endif // NO_INCLUDE_UNION
  779. #include "shdguid.h"
  780. #define SetWindowBits SHSetWindowBits
  781. #define IsSameObject SHIsSameObject
  782. #define IsChildOrSelf SHIsChildOrSelf
  783. #define MenuIndexFromID  SHMenuIndexFromID
  784. #define _GetMenuFromID  SHGetMenuFromID
  785. #define GetCurColorRes SHGetCurColorRes
  786. #define WaitForSendMessageThread SHWaitForSendMessageThread
  787. #define MAX_URL_STRING      INTERNET_MAX_URL_LENGTH
  788. // Stack allocated BSTR (to avoid calling SysAllocString)
  789. typedef struct _SA_BSTR {
  790.     ULONG   cb;
  791.     WCHAR   wsz[MAX_URL_STRING];
  792. } SA_BSTR;
  793. //
  794. //  The cb field of a BSTR is the count of bytes, not including the
  795. //  terminating L('').
  796. //
  797. //
  798. //  DECLARE_CONST_BSTR - Goes into header file (if any)
  799. //  DEFINE_CONST_BSTR  - Creates the variable, must already be declared
  800. //  MAKE_CONST_BSTR    - Combines DECLARE and DEFINE
  801. //
  802. #define DECLARE_CONST_BSTR(name, str) 
  803.  extern const struct BSTR##name { ULONG cb; WCHAR wsz[sizeof(str)/sizeof(WCHAR)]; } name
  804. #define DEFINE_CONST_BSTR(name, str) 
  805.         const struct BSTR##name name = { sizeof(str) - sizeof(WCHAR), str }
  806. #define MAKE_CONST_BSTR(name, str) 
  807.         const struct BSTR##name { ULONG cb; WCHAR wsz[sizeof(str)/sizeof(WCHAR)]; } 
  808.                                 name = { sizeof(str) - sizeof(WCHAR), str }
  809. DECLARE_CONST_BSTR(s_sstrIDMember,         L"id");
  810. DECLARE_CONST_BSTR(s_sstrSubSRCMember,     L"subscribed_url");
  811. DECLARE_CONST_BSTR(s_sstrSRCMember,        L"src");
  812. // The W version of this API has been implemented in shlwapi, so we save code
  813. // and use that version.  If we include w95wraps.h we'll get this definition
  814. // for us, but shell32 isn't single binary yet so we don't use it.
  815. #define ShellMessageBoxW ShellMessageBoxWrapW
  816. //======== Header file hacks =============================================================
  817. //
  818. //  The compiler will tell us if we are defining these NT5-only parameters
  819. //  incorrectly.  If you get "invalid redefinition" errors, it means that
  820. //  the definition in windows.h changed and we need to change to match.
  821. //
  822. #define ASFW_ANY    ((DWORD)-1)
  823. #if _WIN32_WINNT < 0x0500
  824. EXTERN_C BOOL AllowSetForegroundWindow( DWORD dwProcId );
  825. #endif
  826. #define CMIDM_LINK      0x0001
  827. #define CMIDM_COPY      0x0002
  828. #define CMIDM_MOVE      0x0003
  829. // Downlevel shutdown dialog function
  830. DWORD DownlevelShellShutdownDialog(HWND hwndParent, DWORD dwItems, LPCTSTR szUsername);
  831. #ifdef WINNT
  832. // from shell32unicodeformat.c
  833. STDAPI_(DWORD) SHChkDskDriveEx(HWND hwnd, LPWSTR pszDrive);
  834. #endif
  835. //
  836. // On NT, sometimes CreateDirectory succeeds in creating the directory, but, you can not do
  837. // anything with it that directory. This happens if the directory name being created does
  838. // not have room for an 8.3 name to be tagged onto the end of it,
  839. // i.e., lstrlen(new_directory_name)+12 must be less or equal to MAX_PATH.
  840. //
  841. // the magic # "12" is 8 + 1 + 3 for and 8.3 name.
  842. // 
  843. // The following macro is used in places where we need to detect this to make
  844. // MoveFile to be consistent with CreateDir(files  os.c and copy.c use this)
  845. //
  846. #define  IsDirPathTooLongForCreateDir(pszDir)    ((lstrlen(pszDir) + 12) > MAX_PATH)
  847. // Features that we want to be able to turn on and off
  848. // as appropriate for schedule.
  849. // The feature will include the folder size and names of item level items in the infotip.
  850. // Comment out #define FEATURE_FOLDER_INFOTIP in foldertip.h to remove this (it's not 
  851. // sufficient to remove the below include).
  852. #include "foldertip.h"
  853. #endif // _SHELLPRV_H_