#include "StdAfx.h" #include "InstallXmlInfo.h" #include "markup.h" CInstallXmlInfo::CInstallXmlInfo(CString strFile) { CMarkup xml; xml.Load(strFile); xml.FindElem(); xml.IntoElem(); // inside ORDER if( xml.FindElem(_T("install_dir")) ) { CString path; path = GetSysPath(xml.GetAttrib(_T("primarypath"))); //for winxp %localappdata% if(path.IsEmpty()) path = GetSysPath(xml.GetAttrib(_T("secondarypath"))); //for winxp %appdata% this->sysPath = path; this->corpPath = sysPath +_T("\\")+xml.GetAttrib(_T("corppath")); this->productPath = corpPath +_T("\\")+xml.GetAttrib(_T("productpath")); installPaths.Add(this->sysPath); installPaths.Add(this->corpPath); installPaths.Add(this->productPath); xml.IntoElem(); if( xml.FindElem(_T("app")) ) { this->appPath = productPath + _T("\\")+xml.GetData(); installPaths.Add(this->appPath); } if( xml.FindElem(_T("data")) ) { this->dataPath = productPath + _T("\\")+xml.GetData(); installPaths.Add(this->dataPath); } if( xml.FindElem(_T("cache")) ) { this->cachePath = productPath + _T("\\")+xml.GetData(); installPaths.Add(this->cachePath); } if( xml.FindElem(_T("log")) ) { this->logPath = productPath + _T("\\")+xml.GetData(); installPaths.Add(this->logPath); } if( xml.FindElem(_T("temp")) ) { this->tempPath = productPath + _T("\\")+xml.GetData(); installPaths.Add(this->tempPath); } xml.OutOfElem(); } if( xml.FindElem(_T("file_list")) ) { xml.IntoElem(); while( xml.FindElem(_T("file"))) { CFileLocationInfo info; info.fileName = xml.GetData(); info.fileType = xml.GetAttrib(_T("type")); info.subDir = xml.GetAttrib(_T("subdir")); locations.Add(info); } xml.OutOfElem(); } if( xml.FindElem(_T("program_group")) ) { this->programGroup = xml.GetData(); } if( xml.FindElem(_T("shortcut")) ) { xml.IntoElem(); while( xml.FindElem(_T("link"))) { CShortCutInfo info; info.target =xml.GetAttrib(_T("target")); info.display =xml.GetData(); info.pos = xml.GetAttrib(_T("pos")); info.param = xml.GetAttrib(_T("param")); shortcuts.Add(info); } xml.OutOfElem(); } if( xml.FindElem(_T("reg")) ) { regInfo.regItem = xml.GetAttrib(_T("regitem")); xml.IntoElem(); if( xml.FindElem(_T("publisher")) ) { this->regInfo.publisher = xml.GetData(); } if( xml.FindElem(_T("displayname")) ) { this->regInfo.displayName = xml.GetData(); } if( xml.FindElem(_T("displayicon")) ) { this->regInfo.displayIcon = xml.GetData(); } if( xml.FindElem(_T("urlinfoabout")) ) { this->regInfo.urlInfoAbout = xml.GetData(); } if( xml.FindElem(_T("uninstallname")) ) { this->regInfo.uninstallName = xml.GetData(); } xml.OutOfElem(); } xml.OutOfElem(); } CInstallXmlInfo::~CInstallXmlInfo(void) { } CString CInstallXmlInfo::GetSysPath(CString sEnvironmentName) { TCHAR buffer[1024]; DWORD dwRet = GetEnvironmentVariable(sEnvironmentName, buffer, sizeof(buffer)); CString value; if (dwRet > 0) { value = buffer; } return value; }