Leaked source code of windows server 2003
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.

96 lines
2.3 KiB

  1. // File: mrulist.h
  2. #ifndef _MRULIST_H_
  3. #define _MRULIST_H_
  4. typedef struct DWSTR
  5. {
  6. DWORD dw;
  7. LPTSTR psz;
  8. } DWSTR;
  9. typedef VOID * PMRUE; // MRU Entries
  10. enum {
  11. MRUTYPE_SZ = 1,
  12. MRUTYPE_DW = 2,
  13. };
  14. class CMRUList2
  15. {
  16. private:
  17. const DWSTR * m_prgDwStr;// {{cCol, pszKey}, {mruType, pszPrefix1}, {mruType, pszPrefix2},...}
  18. int m_cCol; // number of "columns" (data entries in m_prgDwStr)
  19. int m_cEntryMax; // maximum number of entries
  20. int m_cEntry; // current number of entries
  21. PMRUE * m_rgpEntry; // array of pointers to MRU data
  22. BOOL m_fDirty; // TRUE if data was changed
  23. BOOL m_fReversed; // Load/Save data reversed (old style)
  24. BOOL FValidCol(int i) {return ((i >= 0) && (i < m_cCol));}
  25. BOOL FValidIndex(int i) {return ((i >= 0) && (i < m_cEntry));}
  26. BOOL FDirty() {return m_fDirty;}
  27. BOOL FReversed() {return m_fReversed;}
  28. inline PMRUE GetEntry(int iItem)
  29. {
  30. ASSERT(FValidIndex(iItem));
  31. return m_rgpEntry[iItem];
  32. }
  33. inline int MruTypeForCol(int iCol)
  34. {
  35. ASSERT(FValidCol(iCol));
  36. return m_prgDwStr[1+iCol].dw;
  37. }
  38. inline LPCTSTR PszPrefixForCol(int iCol)
  39. {
  40. ASSERT(FValidCol(iCol));
  41. return m_prgDwStr[1+iCol].psz;
  42. }
  43. inline LPCTSTR PszRegKey(void)
  44. {
  45. return m_prgDwStr[0].psz;
  46. }
  47. VOID ShiftEntriesDown(int cItem);
  48. public:
  49. CMRUList2(const DWSTR * prgDwStr, int cEntryMax, BOOL fReverse = FALSE);
  50. ~CMRUList2();
  51. int GetNumEntries() {return m_cEntry;}
  52. VOID SetDirty(BOOL fDirty) {m_fDirty = fDirty;}
  53. // Generic functions
  54. int FindEntry(PMRUE pEntry);
  55. VOID MoveEntryToTop(int iItem);
  56. int CompareEntry(int iItem, PMRUE pEntry);
  57. PMRUE LoadEntry(RegEntry * pre, int iItem);
  58. VOID StoreEntry(RegEntry * pre, int iItem);
  59. VOID DeleteEntry(PMRUE pEntry);
  60. VOID DeleteEntry(int iItem);
  61. void
  62. DeleteEntry
  63. (
  64. const TCHAR * const primaryString
  65. );
  66. HRESULT Save(void);
  67. LPCTSTR PszEntry(int iItem);
  68. LPCTSTR PszData2(int iItem);
  69. DWORD_PTR PszData3(int iItem);
  70. HRESULT AddEntry(PMRUE pEntry);
  71. HRESULT AddEntry(LPCTSTR pcsz);
  72. HRESULT AddEntry(LPCTSTR pcsz1, LPCTSTR pcsz2);
  73. HRESULT AddEntry(LPCTSTR pcsz1, LPCTSTR pcsz2, DWORD dw3);
  74. };
  75. #endif /* _MRULIST_H_ */
  76.