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.

178 lines
8.2 KiB

  1. #ifndef _CLEANUPWIZ_H_
  2. #define _CLEANUPWIZ_H_
  3. #include <shlobj.h>
  4. #include <shfusion.h>
  5. #include <regstr.h> // REGSTR_PATH_EXPLORER
  6. //
  7. // These flags specify the mode the wizard runs in
  8. //
  9. #define CLEANUP_MODE_NORMAL 0x0
  10. #define CLEANUP_MODE_ALL 0x1
  11. #define CLEANUP_MODE_SILENT 0x2
  12. #define MAX_GUID_STRING_LEN 39
  13. //
  14. // Registry keys used by this app
  15. //
  16. // these values are also used in shell\shell32\unicpp\dcomp.cpp in the desktop cleanup
  17. // properties dialog, so if you change values here, update those too.
  18. //
  19. #define REGSTR_PATH_CLEANUPWIZ REGSTR_PATH_EXPLORER TEXT("\\Desktop\\CleanupWiz")
  20. #define REGSTR_VAL_TIME TEXT("Last used time")
  21. #define REGSTR_VAL_DELTA_DAYS TEXT("Days between clean up")
  22. #define REGSTR_VAL_DONTRUN TEXT("NoRun")
  23. #define REGSTR_PATH_HIDDEN_DESKTOP_ICONS REGSTR_PATH_EXPLORER TEXT("\\HideDesktopIcons\\%s")
  24. #define REGSTR_VALUE_STARTPANEL TEXT("NewStartPanel")
  25. #define REGSTR_VALUE_CLASSICMENU TEXT("ClassicStartMenu")
  26. #define REGSTR_OEM_PATH REGSTR_PATH_SETUP TEXT("\\OemStartMenuData")
  27. #define REGSTR_OEM_TITLEVAL TEXT("DesktopShortcutsFolderName")
  28. #define REGSTR_OEM_OPTIN TEXT("DoDesktopCleanup")
  29. #define REGSTR_WMP_PATH_SETUP TEXT("Software\\Microsoft\\MediaPlayer\\Setup")
  30. #define REGSTR_WMP_REGVALUE TEXT("DesktopShortcut")
  31. #define REGSTR_PATH_OCMANAGER TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Setup\\OC Manager\\Subcomponents")
  32. #define REGSTR_IEACCESS TEXT("IEAccess")
  33. #define REGSTR_MSNCODES TEXT("Software\\Microsoft\\MSN6\\Setup\\MSN\\Codes")
  34. #define REGSTR_MSN_IAONLY TEXT("IAOnly")
  35. #define REGSTR_YES TEXT("yes")
  36. #define DEFAULT_USER TEXT("Default User")
  37. // none of these strings are ever localized, so it's safe to use them
  38. #define REGSTR_SHELLFOLDERS TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders")
  39. #define REGSTR_DESKTOPNAMESPACE TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace")
  40. #define REGSTR_PROFILELIST TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\")
  41. #define REGSTR_MSNCODES TEXT("Software\\Microsoft\\MSN6\\Setup\\MSN\\Codes")
  42. #define REGSTR_PATH_OCMANAGER TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Setup\\OC Manager\\Subcomponents")
  43. #define REGSTR_WMP_PATH_SETUP TEXT("Software\\Microsoft\\MediaPlayer\\Setup")
  44. #define REGSTR_PROFILESDIR TEXT("ProfilesDirectory")
  45. #define REGSTR_ALLUSERS TEXT("AllUsersProfile")
  46. #define REGSTR_DEFAULTUSER TEXT("DefaultUserProfile")
  47. #define REGSTR_DESKTOP TEXT("Desktop")
  48. #define DESKTOP_DIR TEXT("Desktop") // backup in case we can't get the localized version
  49. //
  50. // Flags for CCleanupWiz::Run method
  51. //
  52. const int FCF_NOFLAGS = 0x00;
  53. const int FCF_UNUSED_ITEMS = 0x01;
  54. const int FCF_IGNORE_REGITEMS = 0x02;
  55. //
  56. // enum for figuring what type of desktop item we are dealing with
  57. //
  58. typedef enum eFILETYPE
  59. {
  60. FC_TYPE_REGITEM,
  61. FC_TYPE_LINK,
  62. FC_TYPE_EXE,
  63. FC_TYPE_OTHER,
  64. };
  65. //
  66. // struct used to keep track of which items should
  67. // be cleaned
  68. //
  69. typedef struct
  70. {
  71. LPITEMIDLIST pidl;
  72. BOOL bSelected;
  73. LPTSTR pszName;
  74. HICON hIcon;
  75. FILETIME ftLastUsed;
  76. } FOLDERITEMDATA, * PFOLDERITEMDATA;
  77. //
  78. // Class is designed to clean up the Desktop Folder. It has a couple of
  79. // documented DESKTOP SPECIFIC features, which will need to be fixed
  80. // before it can be used as a generic Folder Cleaner class.
  81. //
  82. class CCleanupWiz
  83. {
  84. public:
  85. CCleanupWiz();
  86. ~CCleanupWiz();
  87. //
  88. // the public interface for using this object
  89. //
  90. STDMETHODIMP Run(DWORD dwCleanMode, HWND hwndParent);
  91. static STDMETHODIMP_(int) GetNumDaysBetweenCleanup(); // returns the number of days to check for between runs
  92. private:
  93. IShellFolder * _psf;
  94. HDSA _hdsaItems;
  95. DWORD _dwCleanMode;
  96. int _iDeltaDays;
  97. BOOL _bInited;
  98. int _cItemsOnDesktop;
  99. HFONT _hTitleFont;
  100. TCHAR _szFolderName[MAX_PATH];
  101. STDMETHODIMP _RunSilent();
  102. STDMETHODIMP_(DWORD) _LoadUnloadHive(HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszHive);
  103. STDMETHODIMP _HideRegItemsFromNameSpace(LPCTSTR szDestPath, HKEY hkey);
  104. STDMETHODIMP _GetDesktopFolderBySid(LPCTSTR szDestPath, LPCTSTR pszSid, LPTSTR pszBuffer, DWORD cchBuffer);
  105. STDMETHODIMP _GetDesktopFolderByRegKey(LPCTSTR pszRegKey, LPCTSTR pszRegValue, LPTSTR szBuffer, DWORD cchBuffer);
  106. STDMETHODIMP _AppendDesktopFolderName(LPTSTR pszBuffer);
  107. STDMETHODIMP _MoveDesktopItems(LPCTSTR pszFrom, LPCTSTR pszTo);
  108. STDMETHODIMP _SilentProcessUserBySid(LPCTSTR pszDestPath, LPCTSTR pszSid);
  109. STDMETHODIMP _SilentProcessUserByRegKey(LPCTSTR pszDestPath, LPCTSTR pszRegKey, LPCTSTR pszRegValue);
  110. STDMETHODIMP _SilentProcessUsers(LPCTSTR pszDestPath);
  111. STDMETHODIMP _LoadDesktopContents();
  112. STDMETHODIMP _LoadMergedDesktopContents();
  113. STDMETHODIMP _ProcessItems();
  114. STDMETHODIMP _ShowBalloonNotification();
  115. STDMETHODIMP _LogUsage();
  116. STDMETHODIMP _ShouldShow(IShellFolder* psf, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlItem);
  117. STDMETHODIMP_(BOOL) _ShouldProcess();
  118. STDMETHODIMP_(BOOL) _IsSupportedType(LPCITEMIDLIST pidl);
  119. STDMETHODIMP_(BOOL) _IsCandidateForRemoval(LPCITEMIDLIST pidl, FILETIME * pftLastUsed);
  120. STDMETHODIMP_(BOOL) _IsRegItemName(LPTSTR pszName);
  121. STDMETHODIMP_(BOOL) _CreateFakeRegItem(LPCTSTR pszDestPath, LPCTSTR pszName, LPCTSTR pszGUID);
  122. STDMETHODIMP _GetUEMInfo(WPARAM wParam, LPARAM lParam, int * pcHit, FILETIME * pftLastUsed);
  123. STDMETHODIMP_(eFILETYPE) _GetItemType(LPCITEMIDLIST pidl);
  124. STDMETHODIMP _HideRegPidl(LPCITEMIDLIST pidl, BOOL bHide);
  125. STDMETHODIMP _HideRegItem(CLSID* pclsid, BOOL fHide, BOOL* pfWasHidden);
  126. STDMETHODIMP _GetDateFromFileTime(FILETIME ftLastUsed, LPTSTR pszDate, int cch );
  127. STDMETHODIMP _InitListBox(HWND hWndListView);
  128. STDMETHODIMP _InitChoosePage(HWND hWndListView);
  129. STDMETHODIMP _InitFinishPage(HWND hWndListView);
  130. STDMETHODIMP _RefreshFinishPage(HWND hDlg);
  131. STDMETHODIMP_(int) _PopulateListView(HWND hWndListView);
  132. STDMETHODIMP_(int) _PopulateListViewFinish(HWND hWndListView);
  133. STDMETHODIMP_(void) _CleanUpDSA();
  134. STDMETHODIMP _CleanUpDSAItem(FOLDERITEMDATA * pfid);
  135. STDMETHODIMP _SetCheckedState(HWND hWndListView);
  136. STDMETHODIMP _MarkSelectedItems(HWND hWndListView);
  137. STDMETHODIMP _InitializeAndLaunchWizard(HWND hwndParent);
  138. INT_PTR STDMETHODCALLTYPE _IntroPageDlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam);
  139. INT_PTR STDMETHODCALLTYPE _ChooseFilesPageDlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam);
  140. INT_PTR STDMETHODCALLTYPE _FinishPageDlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam);
  141. static INT_PTR CALLBACK s_StubDlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam);
  142. } ;
  143. // helper functions
  144. STDAPI_(BOOL) IsUserAGuest();
  145. void CreateDesktopIcons(); // if OEM decides to disable silent mode, then we create icons on desktop
  146. #endif // _CLEANUPWIZ_H_