Пример #1
0
void NewVersionDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
	CDialog::OnShowWindow(bShow, nStatus);

	int iTotalTextLength = ctlDetails.GetWindowTextLength();
	ctlDetails.SetSel(iTotalTextLength, iTotalTextLength);
	BeginWaitCursor();
	CString sResult;
	CWebAccess webAccess;
	webAccess.Get("www.milow.net/site/projects/parnrar/pnrVersions.xml", sResult);

	if (sResult != "")
		{
		MSXML::IXMLDOMDocumentPtr domVersions;	

		if (CoCreateInstance( MSXML::CLSID_DOMDocument, 0, CLSCTX_INPROC_SERVER, MSXML::IID_IXMLDOMDocument, (void**)&domVersions ) != S_OK)
		{
			ctlDetails.ReplaceSel("Error: Failed to create DOMDocument object");
			goto CLEANUP;
		}
		domVersions->loadXML(sResult.GetBuffer(0));
		CString sXml = static_cast<char *>(domVersions->xml);
		if (sXml == "")
		{
			ctlDetails.ReplaceSel("Error: Failed to download version information");
			goto CLEANUP;
		}
		MSXML::IXMLDOMElementPtr eVer = domVersions->selectSingleNode("/Versions/Version");
		CString sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number")));
		if (sVer == theApp.GetMyVersion())
		{
			ctlDetails.ReplaceSel("You are currently running the latest version of Par-N-Rar");
			goto CLEANUP;
		}

		//Get all info about later versions
		CString sText = "You are currently running v" + theApp.GetMyVersion();
		sText += "\n";
		sText += "The latest version is v" + sVer;
		sText += "\n\n";

		MSXML::IXMLDOMNodeListPtr nlVersions = domVersions->selectNodes( "/Versions/Version");	
		for (long l=0; l<nlVersions->length; l++)
		{
			eVer = nlVersions->Getitem(l);
			sVer = static_cast<char *>(_bstr_t(eVer->getAttribute("number")));
			if (sVer == theApp.GetMyVersion())
				break;
			sText += "****************************************************\nVersion " + sVer;
			sText += ": \n";
			sText += static_cast<char *>(eVer->text);
			sText += "\n\n";
		}
		ctlDetails.ReplaceSel(sText);
	}

CLEANUP:
	Resize();
	EndWaitCursor();
}
Пример #2
0
/** @brief Load all Application settings in one shot from the XML file.
* @remarks CoInitialize() or CoInitializeEx() must have been called before using this method.
* @param _sFileName the full path name of an existing file
*/
bool MenuCommandSetCfg::_LoadFile(const std::string& _sFileName)
{
	const _bstr_t XMLDOM_OBJECT= _T("Microsoft.XMLDOM");
	const _bstr_t NODE_DART(_T("uicfg"));
	const _bstr_t NODE_COMMANDS(_T("commands"));
	const _bstr_t NODE_VERSION(_T("version"));
	const _bstr_t NODE_COMMANDLIST(_T("commandlist"));
	const _bstr_t NODE_MENULIST(_T("menulist"));

	bool bResult= false;

	try
	{
		MSXML::IXMLDOMDocumentPtr XMLDom;
		HRESULT hResult = XMLDom.CreateInstance((LPCSTR)XMLDOM_OBJECT);
		if(S_OK==hResult)
		{
			_ClearLists();

			_bstr_t FileName(_sFileName.c_str());

			if(XMLDom->load(FileName))
			{
				MSXML::IXMLDOMNodePtr Root= XMLDom->selectSingleNode(NODE_DART);
				MSXML::IXMLDOMNodePtr XMLNode;
				MSXML::IXMLDOMNodePtr XMLNode2;
				if( Root != NULL )
				{
					//load the file version
					XMLNode = Root->selectSingleNode(NODE_VERSION);
					_LoadFileVersion(XMLNode);

					//load the list of menu items
					XMLNode = Root->selectSingleNode(NODE_COMMANDS);
					if(XMLNode){
						XMLNode2= XMLNode->selectSingleNode(NODE_COMMANDLIST);
						_LoadMenuItemList(XMLNode2);

						XMLNode2= XMLNode->selectSingleNode(NODE_MENULIST);
						_LoadMenuList(XMLNode2);
					}
					bResult= true;
				}
			}
		}
		else{
			TRACE(_T("Failed to load XMLDom (%x)\n"), hResult);
		}
	}
	catch(...){
		TRACE(_T("Exception while loading config file\n"));
	}
	return bResult;
}