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.

66 lines
1.4 KiB

  1. // File: mrulist.h
  2. // CMRUList class - a simple class for maintaining the list of
  3. // most recently used items.
  4. //
  5. // Warning: this class doesn't not perform parameter validation
  6. // and is not safe in a multi-threaded environment
  7. //
  8. // FUTURE: This chews up almost 4K for the string data!
  9. // Allow for generic type.
  10. #ifndef _MRULIST_H_
  11. #define _MRULIST_H_
  12. const int MRU_MAX_ENTRIES = 15;
  13. const int MRU_MAX_STRING = 256;
  14. class CMRUList
  15. {
  16. private:
  17. TCHAR m_szNames[MRU_MAX_ENTRIES][MRU_MAX_STRING];
  18. BOOL m_fDirty;
  19. int m_nValidEntries;
  20. LPTSTR m_pszRegKey;
  21. BOOL ShiftEntries(int nSrc, int nDest, int cEntries=0);
  22. public:
  23. CMRUList();
  24. ~CMRUList();
  25. BOOL Load(LPCTSTR pcszRegKey);
  26. BOOL Save();
  27. int GetNumEntries() { return m_nValidEntries; };
  28. // Note: these functions do not check if a valid index has been passed in
  29. LPCTSTR GetNameEntry(int nEntryIndex) { return m_szNames[nEntryIndex]; };
  30. LPCTSTR PszEntry(int iItem) {return m_szNames[(m_nValidEntries-iItem)-1];};
  31. BOOL AddNewEntry(LPCTSTR pcszName);
  32. int FindEntry(LPCTSTR pcszName);
  33. BOOL MoveEntryToTop(int nIndex);
  34. bool
  35. DeleteEntry
  36. (
  37. const TCHAR * const entry
  38. );
  39. bool
  40. ReplaceEntry
  41. (
  42. const TCHAR * const oldEntry,
  43. const TCHAR * const newEntry
  44. );
  45. bool
  46. AppendEntry
  47. (
  48. const TCHAR * const entry
  49. );
  50. };
  51. #endif // ! _MRULIST_H_