InstallXmlInfo.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #include "StdAfx.h"
  2. #include "InstallXmlInfo.h"
  3. #include "markup.h"
  4. CInstallXmlInfo::CInstallXmlInfo(CString strFile)
  5. {
  6. CMarkup xml;
  7. xml.Load(strFile);
  8. xml.FindElem();
  9. xml.IntoElem(); // inside ORDER
  10. if( xml.FindElem(_T("install_dir")) )
  11. {
  12. CString path;
  13. path = GetSysPath(xml.GetAttrib(_T("primarypath"))); //for winxp %localappdata%
  14. if(path.IsEmpty())
  15. path = GetSysPath(xml.GetAttrib(_T("secondarypath"))); //for winxp %appdata%
  16. this->sysPath = path;
  17. this->corpPath = sysPath +_T("\\")+xml.GetAttrib(_T("corppath"));
  18. this->productPath = corpPath +_T("\\")+xml.GetAttrib(_T("productpath"));
  19. installPaths.Add(this->sysPath);
  20. installPaths.Add(this->corpPath);
  21. installPaths.Add(this->productPath);
  22. xml.IntoElem();
  23. if( xml.FindElem(_T("app")) )
  24. {
  25. this->appPath = productPath + _T("\\")+xml.GetData();
  26. installPaths.Add(this->appPath);
  27. }
  28. if( xml.FindElem(_T("data")) )
  29. {
  30. this->dataPath = productPath + _T("\\")+xml.GetData();
  31. installPaths.Add(this->dataPath);
  32. }
  33. if( xml.FindElem(_T("cache")) )
  34. {
  35. this->cachePath = productPath + _T("\\")+xml.GetData();
  36. installPaths.Add(this->cachePath);
  37. }
  38. if( xml.FindElem(_T("log")) )
  39. {
  40. this->logPath = productPath + _T("\\")+xml.GetData();
  41. installPaths.Add(this->logPath);
  42. }
  43. if( xml.FindElem(_T("temp")) )
  44. {
  45. this->tempPath = productPath + _T("\\")+xml.GetData();
  46. installPaths.Add(this->tempPath);
  47. }
  48. xml.OutOfElem();
  49. }
  50. if( xml.FindElem(_T("file_list")) )
  51. {
  52. xml.IntoElem();
  53. while( xml.FindElem(_T("file")))
  54. {
  55. CFileLocationInfo info;
  56. info.fileName = xml.GetData();
  57. info.fileType = xml.GetAttrib(_T("type"));
  58. info.subDir = xml.GetAttrib(_T("subdir"));
  59. locations.Add(info);
  60. }
  61. xml.OutOfElem();
  62. }
  63. if( xml.FindElem(_T("program_group")) )
  64. {
  65. this->programGroup = xml.GetData();
  66. }
  67. if( xml.FindElem(_T("shortcut")) )
  68. {
  69. xml.IntoElem();
  70. while( xml.FindElem(_T("link")))
  71. {
  72. CShortCutInfo info;
  73. info.target =xml.GetAttrib(_T("target"));
  74. info.display =xml.GetData();
  75. info.pos = xml.GetAttrib(_T("pos"));
  76. info.param = xml.GetAttrib(_T("param"));
  77. shortcuts.Add(info);
  78. }
  79. xml.OutOfElem();
  80. }
  81. if( xml.FindElem(_T("reg")) )
  82. {
  83. regInfo.regItem = xml.GetAttrib(_T("regitem"));
  84. xml.IntoElem();
  85. if( xml.FindElem(_T("publisher")) )
  86. {
  87. this->regInfo.publisher = xml.GetData();
  88. }
  89. if( xml.FindElem(_T("displayname")) )
  90. {
  91. this->regInfo.displayName = xml.GetData();
  92. }
  93. if( xml.FindElem(_T("displayicon")) )
  94. {
  95. this->regInfo.displayIcon = xml.GetData();
  96. }
  97. if( xml.FindElem(_T("urlinfoabout")) )
  98. {
  99. this->regInfo.urlInfoAbout = xml.GetData();
  100. }
  101. if( xml.FindElem(_T("uninstallname")) )
  102. {
  103. this->regInfo.uninstallName = xml.GetData();
  104. }
  105. xml.OutOfElem();
  106. }
  107. xml.OutOfElem();
  108. }
  109. CInstallXmlInfo::~CInstallXmlInfo(void)
  110. {
  111. }
  112. CString CInstallXmlInfo::GetSysPath(CString sEnvironmentName)
  113. {
  114. TCHAR buffer[1024];
  115. DWORD dwRet = GetEnvironmentVariable(sEnvironmentName, buffer, sizeof(buffer));
  116. CString value;
  117. if (dwRet > 0)
  118. {
  119. value = buffer;
  120. }
  121. return value;
  122. }