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.

74 lines
2.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: strcache.h
  4. //
  5. // Contents: Insert object string caching support
  6. //
  7. // Classes: CStringCache
  8. //
  9. // History: 02-May-99 MPrabhu Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #ifndef _STRCACHE_H_
  13. #define _STRCACHE_H_
  14. #if USE_STRING_CACHE==1
  15. // Allocate enough memory to carry 64 UNICODE strings of MAX length each at init
  16. #define CACHE_MAX_BYTES_INITIAL (64 * (OLEUI_CCHKEYMAX_SIZE*2) * sizeof(TCHAR))
  17. // Allocate enough memory for 128 string offsets at Init time
  18. #define MAX_INDEX_ENTRIES_INITIAL 128
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CStringCache
  22. //
  23. // Contents: Maintains the cache of insert object strings.
  24. //
  25. // History: 02-May-99 MPrabhu Created
  26. //
  27. //----------------------------------------------------------------------------
  28. class CStringCache {
  29. public:
  30. CStringCache();
  31. ~CStringCache();
  32. BOOL Init();
  33. void CleanUp();
  34. void NewCall(DWORD flags, DWORD cClsidExclude);
  35. BOOL AddString(LPTSTR lpStrAdd);
  36. LPCTSTR NextString();
  37. void ResetEnumerator();
  38. BOOL FlushCache();
  39. BOOL IsUptodate();
  40. BOOL OKToUse();
  41. private:
  42. BOOL ExpandStringTable();
  43. BOOL ExpandOffsetTable();
  44. BYTE *m_pStrings; // All strings are stored sequentially in this.
  45. ULONG *m_pOffsetTable; // Array of offsets points to location of
  46. // strings in m_pStrings.
  47. ULONG m_ulStringCount; // Current count of strings.
  48. ULONG m_ulMaxStringCount; // Current limit for # of strings cache can hold
  49. ULONG m_ulMaxBytes; // Current limit for byte size of string cache
  50. // Since the cache grows as needed, both of these can
  51. // change over time. However, that will be very rare.
  52. ULONG m_ulNextStringNum; // 1 based string sequence # for enumeration
  53. HANDLE m_hRegEvent; // We use these to watch changes to HKCR\ClsId
  54. HKEY m_hRegKey; // Set to HKCR\ClsID if Init() succeeds
  55. DWORD m_ioFlagsPrev; // Flags passed to a previous InsertObject call
  56. DWORD m_cClsidExcludePrev;// cClsidExclude from a previous InsertObj call
  57. };
  58. // Functions called through OleUIInitialize/OleUIUninitialize during
  59. // DLL_PROCESS_ATTACH/DETACH.
  60. BOOL InsertObjCacheInitialize();
  61. void InsertObjCacheUninitialize();
  62. #endif // USE_STRING_CACHE==1
  63. #endif //_STRCACHE_H_