Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.8 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: shelldll.h
  4. //
  5. // Module: CMMON32.EXE and CMDIAL32.DLL
  6. //
  7. // Synopsis: Definition of CShellDll, a shell32.dll wrapper.
  8. //
  9. // Copyright (c) 1998-1999 Microsoft Corporation
  10. //
  11. // Author: fengsun Created 01/12/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef SHELLDLL_H
  15. #define SHELLDLL_H
  16. #include <windows.h>
  17. #include <shlobj.h>
  18. //
  19. // the following is to circumvent the NT 5.0 windows.h
  20. //
  21. #ifdef WIN32_LEAN_AND_MEAN
  22. #include <shellapi.h>
  23. #endif
  24. //+---------------------------------------------------------------------------
  25. //
  26. // class CShellDll
  27. //
  28. // Description: A class to dynamic load/unload shell32.dll to reduce the
  29. // workingset under win95
  30. //
  31. // History: fengsun Created 1/12/98
  32. //
  33. //----------------------------------------------------------------------------
  34. class CShellDll
  35. {
  36. public:
  37. CShellDll(BOOL fKeepDllLoaded = FALSE);
  38. ~CShellDll();
  39. BOOL Load(); // can call even if loaded
  40. void Unload(); // can call even if not loaded
  41. BOOL IsLoaded();
  42. // For ShellExecuteEx
  43. BOOL ExecuteEx(LPSHELLEXECUTEINFO lpExecInfo);
  44. // For ShellNotifyIcon
  45. BOOL NotifyIcon(DWORD dwMessage, PNOTIFYICONDATA pnid );
  46. HRESULT ShellGetSpecialFolderLocation(HWND, int, LPITEMIDLIST *);
  47. BOOL ShellGetPathFromIDList(LPCITEMIDLIST, LPTSTR);
  48. HRESULT ShellGetMalloc(LPMALLOC * ppMalloc);
  49. //
  50. // These three types and the associated function pointers were made public
  51. // so that they could be passed to GetUsersApplicationDataDir. Because of
  52. // name decoration, passing the classes wrappers doesn't work.
  53. //
  54. typedef HRESULT (WINAPI* SHGetSpecialFolderLocationSpec)(HWND, int, LPITEMIDLIST *);
  55. typedef BOOL (WINAPI* SHGetPathFromIDListSpec)(LPCITEMIDLIST, LPTSTR);
  56. typedef HRESULT (WINAPI* SHGetMallocSpec)(LPMALLOC * ppMalloc);
  57. SHGetSpecialFolderLocationSpec m_pfnSHGetSpecialFolderLocation;
  58. SHGetPathFromIDListSpec m_pfnSHGetPathFromIDList;
  59. SHGetMallocSpec m_pfnSHGetMalloc;
  60. protected:
  61. typedef BOOL (WINAPI *SHELLEXECUTEEXPROC)(LPSHELLEXECUTEINFOW lpExecInfo);
  62. typedef BOOL (WINAPI *SHELL_NOTIFYICONPROC)(DWORD dwMessage, PNOTIFYICONDATAW pnid );
  63. HINSTANCE m_hInstShell;
  64. BOOL m_KeepDllLoaded;
  65. SHELLEXECUTEEXPROC m_fnShellExecuteEx;
  66. SHELL_NOTIFYICONPROC m_fnShell_NotifyIcon;
  67. };
  68. inline BOOL CShellDll::ExecuteEx(LPSHELLEXECUTEINFOW lpExecInfo)
  69. {
  70. if (!Load())
  71. {
  72. return FALSE;
  73. }
  74. return m_fnShellExecuteEx(lpExecInfo);
  75. }
  76. inline BOOL CShellDll::NotifyIcon(DWORD dwMessage, PNOTIFYICONDATAW pnid )
  77. {
  78. if (!Load())
  79. {
  80. return FALSE;
  81. }
  82. BOOL fRet = m_fnShell_NotifyIcon(dwMessage,pnid);
  83. return fRet;
  84. }
  85. inline BOOL CShellDll::IsLoaded()
  86. {
  87. return m_hInstShell != NULL;
  88. }
  89. #endif