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.

165 lines
4.0 KiB

  1. #include "DBDataStructures.h"
  2. #ifndef __DATABASE
  3. #define __DATABASE
  4. #endif
  5. class CSTRING;
  6. class CDatabase {
  7. public:
  8. static CSTRING m_DBName;
  9. static GUID m_DBGuid;
  10. static PDB m_pDB;
  11. static CSTRING m_szCurrentDatabase;// Name of the SDB File
  12. PDBRECORD m_pRecordHead;
  13. PSHIMDESC m_pShimList;
  14. PDBLAYER m_pLayerList;
  15. PAPPHELP m_pAppHelp;
  16. static UINT m_uStandardImages;
  17. BOOL m_bDirty;
  18. void
  19. ReadAppHelp(
  20. void);
  21. BOOL
  22. AddAppHelp(
  23. TAGID tiAppHelp
  24. );
  25. protected:
  26. private:
  27. BOOL STDCALL WriteString(HANDLE hFile, CSTRING & szString, BOOL bAutoCR);
  28. void STDCALL ResolveMatch(CSTRING & szStr, PMATCHENTRY pMatch);
  29. public:
  30. CDatabase()
  31. {
  32. m_pDB = NULL;
  33. m_pRecordHead = NULL;
  34. m_pShimList = NULL;
  35. m_pLayerList = NULL;
  36. m_pAppHelp = NULL;
  37. m_DBName.Init();
  38. m_szCurrentDatabase = TEXT("Untitled.SDB");
  39. m_bDirty = FALSE;
  40. //m_ShimList.Init();
  41. //m_LayerList.Init();
  42. }
  43. ~CDatabase()
  44. {
  45. m_DBName.Release();
  46. m_szCurrentDatabase.Release();
  47. //
  48. //BUGBUG
  49. //
  50. // When/where is the layetlsit and the layerlist freed ?
  51. //m_ShimList.Release();
  52. //m_LayerList.Release();
  53. }
  54. BOOL STDCALL NewDatabase(BOOL bShowDialog);
  55. BOOL STDCALL ChangeDatabaseName(void);
  56. BOOL STDCALL CloseDatabase(void);
  57. /*.........................NOT USED .....................
  58. //BOOL STDCALL ReadShim(TAGID, CShimDesc **);
  59. //CShimDesc * ReadShim(TAGID tShim);
  60. //BOOL STDCALL ReadLayer(TAGID tLayer, CLayer **);
  61. //BOOL STDCALL ReadRecord(TAGID tRecord, CDBRecord **);
  62. //BOOL STDCALL ReadLayer(TAGID tLayer, PDBLAYER);
  63. //BOOL STDCALL AddLayer(PDBLAYER);
  64. ...........................................................*/
  65. //BOOL STDCALL ReadShim(TAGID tShim, PSHIMDESC);
  66. UINT STDCALL DeleteRecord(PDBRECORD pRecord);
  67. BOOL STDCALL OpenDatabase(CSTRING & szFilename, BOOL bGlobal);
  68. BOOL STDCALL InsertRecord(PDBRECORD pRecord);
  69. static BOOL STDCALL ReadRecord(TAGID tagParent, PDBRECORD pRecord, PDB pDB = NULL);
  70. static CSTRING STDCALL ReadDBString(TAGID tagID, PDB pDB = NULL);
  71. void STDCALL ReadShims(BOOL bPermanent);
  72. void STDCALL AddShim(TAGID tShim, BOOL bShim, BOOL bPermanent, BOOL bLayer);
  73. BOOL STDCALL SaveDatabase(CSTRING & szFilename);
  74. CSTRINGList * STDCALL DisassembleRecord(PDBRECORD pRecordIn, BOOL bChildren, BOOL bSiblings, BOOL bIncludeLocalLayers, BOOL bFullXML, BOOL bAllowGlobal, BOOL bTestRun);
  75. BOOL STDCALL WriteXML(CSTRING & szFilename, CSTRINGList * pString);
  76. static BOOL STDCALL InvokeCompiler(CSTRING & szInCommandLine);
  77. static DWORD STDCALL GetEntryFlags(HKEY hKeyRoot, GUID & Guid);
  78. static BOOL STDCALL SetEntryFlags(HKEY hKeyRoot, GUID & Guid, DWORD dwFlags);
  79. static BOOL CleanUp(); //Delete the test.sdb
  80. static BOOL SystemDB(CSTRING Filename)
  81. {
  82. HSDB hSDB = SdbInitDatabase(HID_DOS_PATHS, Filename);
  83. PDB pDB = SdbOpenDatabase(Filename,DOS_PATH);
  84. BOOL bSystemDB = FALSE;
  85. if ( NULL == pDB )
  86. return FALSE;
  87. TAGID tiDatabase = SdbFindFirstTag(pDB, TAGID_ROOT, TAG_DATABASE);
  88. if ( 0 != tiDatabase ) {
  89. TAGID tName;
  90. // Read in the database and name.
  91. tName = SdbFindFirstTag(pDB, tiDatabase, TAG_NAME);
  92. if ( 0 != tName ){
  93. CSTRING dbName = ReadDBString(tName, pDB);
  94. if (dbName == TEXT("Microsoft Windows Application Compatibility Message Database"))
  95. bSystemDB = TRUE;
  96. }//if ( 0 != tName
  97. }//if ( 0 != tiDatabase )
  98. SdbCloseDatabase(pDB);
  99. return bSystemDB;
  100. }//static BOOL SystemDB(CSTRING szFilename)
  101. };