//比较两个BSTR类型的字符串(忽略大小写) int CompareBSTRNoCase(_bstr_t bstr1, _bstr_t bstr2) { CComBSTR comBstr1(bstr1.GetBSTR()); CComBSTR comBstr2(bstr2.GetBSTR()); comBstr1.ToLower(); comBstr2.ToLower(); if (comBstr1 == comBstr2) return 0; else if (comBstr1 > comBstr2) return 1; else return -1; }
void MiniBrowserWebHost::loadURL(_bstr_t& url) { ::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETTEXT), 0, reinterpret_cast<LPARAM>(url.GetBSTR())); }
// These are ReferenceMaker methods but they are called when // the GUP is saved, which is not in the reference hierarchy. // These methods cannot use the reference hierarchy for // saving and loading data. IOResult CMaxMaterialCollection::Save(ISave *isave) { // Since the library can't be saved using the reference // hierarchy, we will use XML. This is imperfect, but // for the tool palette it should be enough, since the basis of // materials in the tool palette is also XML. // Don't save anything we don't need to. if (mpScratchMtlLib == NULL || mpScratchMtlLib->Count() <= 0) return IO_OK; // Get the VIZ Importer/Exporter CComPtr<IVIZPointerClient> pPointerClient; HRESULT hr = GetXMLImpExp(&pPointerClient); if(hr != S_OK) return IO_ERROR; // Get the export interface CComQIPtr<IMaterialXmlExport> pILib = pPointerClient; ATLASSERT(pILib); if(!pILib) return IO_ERROR; // Create an XML document CComPtr<IXMLDOMDocument> doc; hr = doc.CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER); if (hr != S_OK || doc == NULL) return IO_ERROR; CComPtr<IXMLDOMElement> materials; hr = doc->createElement(sMaterialsTag.GetBSTR(), &materials); if (FAILED(hr) || materials == NULL) return IO_ERROR; hr = doc->putref_documentElement(materials); if (FAILED(hr)) return IO_ERROR; #ifdef TP_SINGLE_DYNAMIC_MTL_PALETTE //WIP The pesistence of scratch materials needs to be rethought. I'd like //to save the dynamic catalog from ToolPaletteGUP. Dynamic tools should be coupled //to their scene item through perssited monikers. The persistence of the "items" should //be completely independent. I think this means the scratchlib should be referenced by //the scene. //The immediate issue is that when using a single palette for all the dynamic materials, //inscene materials are being saved twice. We'll try to fix this by deleting them first. //At this point the refhierarchy is already saved so we should be ok. deleteMaterials(true, true, false); #endif //if the scratch palette contains materials with real references to them (e.g. Filelink) //then they could potentiall be saved twice: once by the ref hierarchy and once in xml. //Therefore we remove them now //deleteReferencedScratchMaterials(); hr = Fire_OnSaveScratchMaterials(this, materials); if (FAILED(hr)) return IO_ERROR; if (hr != S_OK) return IO_OK; // Nothing to save // Now read the data from the XML document and write it // to the MAX data stream _bstr_t xml; hr = doc->get_xml(xml.GetAddress()); if (hr != S_OK) return IO_ERROR; isave->BeginChunk(kScratchLibChunk); IOResult res = isave->WriteCString(LPCTSTR(xml)); isave->EndChunk(); return res; }
int ZDMHTMaker::DownloadHtmlToMHT(_bstr_t p_wcURL,_bstr_t p_wcFilePath,_bstr_t p_wcUsername ,_bstr_t p_wcPassword ) { if(0 == p_wcURL .length() || 0 == p_wcFilePath.length()) { return 1; } if(L'\\' != p_wcFilePath.GetBSTR()[p_wcFilePath.length() - 1]) { p_wcFilePath += L"\\"; } IMessage *pMsg=NULL; IConfiguration* pConfig = NULL; _Stream* pStm = NULL; HRESULT hr=CoCreateInstance( __uuidof(Message), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMessage), (void**)&pMsg); if(FAILED(hr)) { return 2; } hr=CoCreateInstance(__uuidof(Configuration),NULL,CLSCTX_INPROC_SERVER,__uuidof(IConfiguration),(void**)&pConfig); if(FAILED(hr)) { return 2; } hr = pMsg->put_Configuration (pConfig); if(FAILED(hr)) { return 2; } try { hr = pMsg->CreateMHTMLBody(p_wcURL,cdoSuppressNone,p_wcUsername,p_wcPassword ); if(FAILED(hr)) { return 3; } } catch(_com_error err) { pMsg->Release(); return 3; } hr = pMsg->GetStream(&pStm); if(FAILED(hr)) { return 4; } BSTR rawHtml = 0; hr = pMsg->get_HTMLBody(&rawHtml); _bstr_t html(rawHtml); std::wstring str = html; int start = str.find(L"<title>"); int end = str.find(L"</title>"); if(start > 0 && end > start + 7) { p_wcFilePath += str.substr(start+7,end-start-7).c_str(); p_wcFilePath += ".mht"; } else { p_wcFilePath += L"unknown.mht"; } str.erase(0,str.size()-1); SysFreeString(rawHtml); hr = pStm->SaveToFile( p_wcFilePath,adSaveCreateOverWrite); if(FAILED(hr)) { return 5; } pMsg->Release(); pStm->Release(); return 0; }
void WinLauncher::setUserAgent(_bstr_t& customUserAgent) { webView()->setCustomUserAgent(customUserAgent.GetBSTR()); }