HRESULT CJSProxyObj::SetEventNames() { ITypeInfo* pInfo; if (m_pTypeInfo == nullptr) pInfo = theApp.m_pEventTypeInfo.p; else pInfo = m_pTypeInfo.p; TYPEATTR *pta = nullptr;; HRESULT hr = pInfo->GetTypeAttr(&pta); if (FAILED(hr)) return hr; BSTR bstrName = ::SysAllocString(L""); FUNCDESC *pfd = nullptr; unsigned int uiNames = 0; for (int i = 0; i < pta->cFuncs; i++) { hr = pInfo->GetFuncDesc(i, &pfd); if (FAILED(hr)) continue; hr = pInfo->GetNames(pfd->memid, &bstrName, 1, &uiNames); if (SUCCEEDED(hr) && bstrName && SysStringLen(bstrName)) { m_mapDispId.Add(pfd->memid, bstrName); ATLTRACE(_T("*********Add function '%s' in Tangram*******\r\n"), OLE2T(bstrName)); } pInfo->ReleaseFuncDesc(pfd); pfd = nullptr; } pInfo->ReleaseTypeAttr(pta); return hr; }
const CCOMString& CCOMString::operator=(BSTR bstrStr) { USES_CONVERSION; int nLen = _tcslen(OLE2T(bstrStr)); StringCopy(nLen, OLE2T(bstrStr)); return *this; }
/* ---------------------------- FILE IO ----------------------------------*/ STDMETHODIMP CFACE::fReadInteger( BSTR Category, BSTR KeyName, LONG Defaults , LONG *pVal){ USES_CONVERSION; *pVal = GetPrivateProfileInt( OLE2T( Category ) , OLE2T( KeyName ) , Defaults , WritingPath ); return S_OK; }
void CDlgIDirectoryObject::ShowAttributes() { ADS_OBJECT_INFO *pInfo; HRESULT hr; hr = m_pDirObject->GetObjectInformation(&pInfo); if (!SUCCEEDED(hr) ) { return; } ///////////////////////////////////////////// // Show the attributes in the UI ///////////////////////////////////////////// USES_CONVERSION; m_sRDN = OLE2T(pInfo->pszRDN); m_sDN = OLE2T(pInfo->pszObjectDN); m_sParent = OLE2T(pInfo->pszParentDN); m_sClass = OLE2T(pInfo->pszClassName); m_sSchema = OLE2T(pInfo->pszSchemaDN); /////////////////////////////////////////////////////////// // Do not forget to clean-up the memory using FreeADsMem! ////////////////////////////////////////////////////////// FreeADsMem( pInfo ); }
void CDrawMenu::AddMenuItems(HMENU hMenu, int& nIndex, int nDepth) { USES_CONVERSION; HTREEITEM hItem = NULL; while (nIndex < m_arrItems.GetSize()) { CMenuItem& item = m_arrItems[nIndex]; int nItemDepth = 0; LPCWSTR p = item.m_bstrText; while (*p++ == '.') nItemDepth++; if (nItemDepth < nDepth) { nIndex--; break; } int nNextItemDepth = nItemDepth; if (nIndex + 1 < m_arrItems.GetSize()) { nNextItemDepth = 0; CMenuItem& itemNext = m_arrItems[nIndex + 1]; LPCWSTR p = itemNext.m_bstrText; while (*p++ == '.') nNextItemDepth++; } if (nNextItemDepth > nItemDepth) { HMENU hNewMenu = CreatePopupMenu(); ATLASSERT(hNewMenu != NULL); AddMenuItems(hNewMenu, ++nIndex, nDepth + 1); AppendMenu(hMenu, MF_POPUP, (UINT)hNewMenu, OLE2T(item.m_bstrText + nItemDepth)); } else { CComBSTR bstrItemText = item.m_bstrText + nItemDepth; if (bstrItemText == L"-") { AppendMenu(hMenu, MF_SEPARATOR, 0, 0); } else { UINT uFlags = MF_STRING; if ((item.m_dwState & MenuStateDisable) != 0) uFlags |= MF_GRAYED; if ((item.m_dwState & MenuStateCheck) != 0) uFlags |= MF_CHECKED; AppendMenu(hMenu, uFlags, nIndex + 1, OLE2T(bstrItemText)); } } nIndex++; } }
STDMETHODIMP CFACE::fReadString( BSTR Category, BSTR KeyName, BSTR Default, BSTR lpBuffer ){ USES_CONVERSION; GetPrivateProfileString( OLE2T( Category ) , OLE2T( KeyName ) , OLE2T( Default ) , OLE2T( lpBuffer ) , 256 , WritingPath ); return S_OK; }
STDMETHODIMP CFACE::fWriteString( BSTR Category, BSTR KeyName, BSTR Data){ USES_CONVERSION; if ( !WritePrivateProfileString( OLE2T( Category ), OLE2T( KeyName ) , OLE2T( Data ) , WritingPath ) ) LogPut( FATAL , IDS_ERR_INVALIDFILE ); return S_OK; }
CCOMString::CCOMString(BSTR bstrString) { USES_CONVERSION; m_pszString = NULL; int nLen = _tcslen(OLE2T(bstrString)); AllocString(nLen); _tcsncpy(m_pszString, OLE2T(bstrString), nLen); }
HRESULT __stdcall CoCOMServer::ahkdll(/*in,optional*/VARIANT filepath,/*in,optional*/VARIANT options,/*in,optional*/VARIANT params,/*out*/UINT_PTR* hThread) { USES_CONVERSION; TCHAR buf1[MAX_INTEGER_SIZE],buf2[MAX_INTEGER_SIZE],buf3[MAX_INTEGER_SIZE]; if (hThread==NULL) return ERROR_INVALID_PARAMETER; *hThread = com_ahkdll(filepath.vt == VT_BSTR ? OLE2T(filepath.bstrVal) : Variant2T(filepath,buf1) ,options.vt == VT_BSTR ? OLE2T(options.bstrVal) : Variant2T(options,buf2) ,params.vt == VT_BSTR ? OLE2T(params.bstrVal) : Variant2T(params,buf3)); return S_OK; }
STDMETHODIMP CFACE::fWriteInteger( BSTR Category, BSTR KeyName, LONG Data){ USES_CONVERSION; TCHAR DataString[ 256 ] ; ZeroMemory( DataString , sizeof(DataString) ); wsprintf( DataString , _T( "%l" ) , Data ); if ( !WritePrivateProfileString( OLE2T( Category ), OLE2T( KeyName ) , DataString , WritingPath ) ) LogPut( FATAL , IDS_ERR_INVALIDFILE ); return S_OK; }
STDMETHODIMP CMktStructureBaseDlg::OnOption(PP::OptionParams *Params, PP::OptionInfo *Results, VARIANT_BOOL bLast) { USES_CONVERSION; HRESULT hr = S_OK; DoEvents(); if(m_bCanceled) return hr; /* if(bLast==VARIANT_FALSE && m_opts.m_enProviderType == enMyTrackPriceProvider) { if( fEQZero(Results->Last) && fEQZero(Results->Bid) && fEQZero(Results->Ask) ) return S_OK; } */ if(bLast==VARIANT_FALSE && Results->ExpirationDate < int(vt_date::GetCurrentDate())) return S_OK; stocks_map::iterator it = m_stocks.find (Params->UnderlyingSymbol); if (it != m_stocks.end()) try { USES_CONVERSION; if (bLast) { it->second.m_bGotOptions = true; UpdateProgress(it); return hr; } CDBLayout db; db.Connect(); db.UpdateOptionData (it->second.m_nID, Params, Results); db.Disconnect(); CString strMsg; strMsg.Format(IDS_MKTSTRUCTURE_GOTOPTION, OLE2T(Params->UnderlyingSymbol), OLE2T(Results->Series) ); it->second.m_lGotOptions++; StatusMessage (strMsg, false); UpdateProgress(it); } catch (_com_error & e) { ErrorMessage(e); Stop(); } return hr; }
STDMETHODIMP CTangramOutLookPlusExplorer::put_UIScript(BSTR bstrKey, BSTR newVal) { CString strKey = OLE2T(bstrKey); if (strKey != _T("")) { map<CString, CString>::iterator it = m_mapUIScript.find(strKey); if (it != m_mapUIScript.end()) { m_mapUIScript.erase(it); } m_mapUIScript[strKey] = OLE2T(newVal); } return S_OK; }
STDMETHODIMP CFACE::Snd_Open( LONG BufferID , BSTR FileName ){ USES_CONVERSION; // 開始 LogBegin( _T( "Snd_Open" ) ); //モードチェックと範囲チェック CHECK_MODE( dwSndMode ); CHECK_RANGE_STR( BufferID , 0 , dwBufferNum , "Sound系関数(Snd_Open)->BufferID" ); /* スプライトへのアクセスポインタ -- */ BUFFERS *lpBuffer = &Buffers[ BufferID ]; lpBuffer->Clear( ); /* ファイルへのパスを取得する */ // ログアウト LogPut( CONTINUE , IDS_LOG_LOADFROMFILE , OLE2T( FileName ) , BufferID ); TCHAR FilePath[ MAX_PATH ] , lpFormatStr[ 64 ]; if ( !GetFilePath( OLE2T( FileName ) , FilePath ) ) LogPut( FATAL , IDS_ERR_FILENOTFOUND ); lpBuffer->SndPts = fopen( FilePath , _T( "rb" ) ); // Check OGG Vorbis File? if ( ogg_Open( lpBuffer ) != S_OK ){ // Check WAV File? if ( wav_Open( lpBuffer ) != S_OK ) LogPut( FATAL , IDS_ERR_INVALIDFILE ); else lstrcpy( lpFormatStr , _T( " ** WavFile **" ) ); }else lstrcpy( lpFormatStr , _T(" ** OGGVorbisFile ** " ) ); // SoundBuffer構築構造体を初期化 lpBuffer->Make( BufferID == 0 ); /* Notify定義 */ if ( BufferID == 0 ){ SAFE_RELEASE( Notify ); // DirectSoundNotifyの作成 lpBuffer->SecBuf->QueryInterface( IID_IDirectSoundNotify ,(LPVOID*)&Notify ); DSBPOSITIONNOTIFY pn[3]; pn[0].dwOffset = lpBuffer->WaveFormat.nAvgBytesPerSec * BufferSec - 1; pn[0].hEventNotify = hEvent[ 0 ]; pn[1].dwOffset = lpBuffer->WaveFormat.nAvgBytesPerSec * BufferSec / 2; pn[1].hEventNotify = hEvent[ 1 ]; pn[2].dwOffset = DSBPN_OFFSETSTOP; // 再生停止 pn[2].hEventNotify = hEvent[ 2 ]; Notify->SetNotificationPositions( 3 , pn ); } // ログアウト LogPut( CONTINUE , IDS_LOG_SOUNDINFO , lpFormatStr ); LogQuit( ); return S_OK; }
void DumpIID(REFIID iid, LPCTSTR pszClassName) { USES_CONVERSION; CRegKey key; TCHAR szName[100]; DWORD dwType; DWORD dw = sizeof(szName); LPOLESTR pszGUID = NULL; if (FAILED(StringFromCLSID(iid, &pszGUID))) return; OutputDebugString(pszClassName); OutputDebugString(_T(" - ")); bool bFound = false; // Attempt to find it in the interfaces section if (key.Open(HKEY_CLASSES_ROOT, _T("Interface"), KEY_READ) == ERROR_SUCCESS) { if (key.Open(key, OLE2T(pszGUID), KEY_READ) == ERROR_SUCCESS) { *szName = 0; if (RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw) == ERROR_SUCCESS) { OutputDebugString(szName); bFound = true; } } } // Attempt to find it in the clsid section else if (key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ) == ERROR_SUCCESS) { if (key.Open(key, OLE2T(pszGUID), KEY_READ) == ERROR_SUCCESS) { *szName = 0; if (RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw) == ERROR_SUCCESS) { OutputDebugString(_T("(CLSID\?\?\?) ")); OutputDebugString(szName); bFound = true; } } } if (!bFound) OutputDebugString(OLE2T(pszGUID)); OutputDebugString(_T("\n")); CoTaskMemFree(pszGUID); }
void CTangramExcelPlusWB::OnSheetActivate(IDispatch* Sh) { CComQIPtr<Excel::_Worksheet> pSheet(Sh); if(pSheet) { CComBSTR bstrName(L""); pSheet->get_Name(&bstrName); CString strName = OLE2T(bstrName); CTangramXmlParse* pParse2 = GetChild(strName); if(pParse2==NULL) pParse2 = GetChild(_T("Default")); if(pParse2) { HWND hWnd = ::GetActiveWindow(); HWND m_hClientWnd = ::FindWindowEx(hWnd,NULL,_T("XLDESK"),NULL); HWND m_hWorkBookWnd = (HWND) ::SendMessage(m_hClientWnd,WM_MDIGETACTIVE,0,0); CTangramExcelPlusWBWnd* pExcelWorkBookWnd = (CTangramExcelPlusWBWnd*)::SendMessage(m_hWorkBookWnd,WM_TANGRAMDATA,0,0); pExcelWorkBookWnd->m_strActiveSheetName = strName; CComPtr<ITangramNode> pNode; pExcelWorkBookWnd->m_pWorkBook->m_pFrame->Extend(bstrName, CComBSTR(pParse2->xml()), &pNode); // if(theApp.m_bOldVer) // { // if(pExcelWorkBookWnd&&pExcelWorkBookWnd->m_pWorkBook->m_pFrame) // { //pExcelWorkBookWnd->m_pWorkBook->m_pFrame->ModifyHost((LONGLONG)pExcelWorkBookWnd->m_pHeplerWnd->m_hWnd,(LONGLONG)pExcelWorkBookWnd->m_pHeplerWnd->m_pChild->m_hWnd); // theApp.m_pTangramCore->NavigateXTML((LONGLONG)pExcelWorkBookWnd->m_pHeplerWnd->m_pChild->m_hWnd,CComBSTR(pParse2->xml()),&pNode); //pExcelWorkBookWnd->m_pWorkBook->m_pFrame->ModifyHost((LONGLONG)hWnd,(LONGLONG)m_hClientWnd); // } // } // else // theApp.m_pTangramManager->NavigateXTML((LONGLONG)m_hClientWnd,CComBSTR(pParse2->xml()),&pNode); } } }
STDMETHODIMP CShellExt::XPersistFileExt::Load(LPCOLESTR wszFile, DWORD dwMode) { METHOD_PROLOGUE(CShellExt, PersistFileExt); USES_CONVERSION; _tcscpy(pThis->m_szFile, OLE2T((WCHAR*)wszFile)); return S_OK; }
static void ErrorDump() { #if 0 USES_CONVERSION; CDBErrorInfo einfo; BSTR bstrDescription; ULONG nRecords = 0; HRESULT hr = einfo.GetErrorRecords(&nRecords); if(SUCCEEDED(hr) && nRecords > 0) { LCID lcid = GetSystemDefaultLCID(); for(ULONG nIndex = 0; nIndex < nRecords; nIndex++) { hr = einfo.GetAllErrorInfo(nIndex, lcid, &bstrDescription); if(SUCCEEDED(hr)) { AfxMessageBox(OLE2T(bstrDescription)); SysFreeString(bstrDescription); } } } #endif USES_CONVERSION; CComPtr<IErrorInfo> pErrInfo; HRESULT hr = ::GetErrorInfo(0, &pErrInfo); if(SUCCEEDED(hr)) { _bstr_t bstrErrDescription; pErrInfo->GetDescription((BSTR *) &bstrErrDescription); CString strDescription = W2T(bstrErrDescription); OutputDebugString(strDescription); } }
STDMETHODIMP CTangramTreeView::AddTreeNode(long hItem, BSTR bstrXml) { if(m_pTangramHtmlTreeWnd) { CTangramXmlParse m_Parse; if(m_Parse.LoadXml(OLE2T(bstrXml))) { int nCount = 0; if((HTREEITEM)hItem) { HTREEITEM hChild = m_pTangramHtmlTreeWnd->GetChildItem((HTREEITEM)hItem); CTangramXHtmlTreeNode *pXTCD = m_pTangramHtmlTreeWnd->GetItemDataStruct((HTREEITEM)hChild); if(pXTCD->m_bWaitingFor) m_pTangramHtmlTreeWnd->DeleteItem(hChild); } CTangramXHtmlTreeNode *pXTCD = m_pTangramHtmlTreeWnd->GetItemDataStruct((HTREEITEM)hItem); if(pXTCD) pXTCD->m_strTangramXML = _T(""); m_pTangramHtmlTreeWnd->LoadXml(&m_Parse,(HTREEITEM)hItem,nCount); m_pTangramHtmlTreeWnd->Expand((HTREEITEM)hItem,TVE_EXPAND); } } return S_OK; }
HRESULT CBasePropSetter::GetNumericVal(const TCHAR *szName, DWORD *pdwVal, int iBase = 10) { if ((iBase != 10) && (iBase != 16)) { return E_INVALIDARG; } BSTR bstrVal; HRESULT hr = FindVal(szName, &bstrVal); if (SUCCEEDED(hr)) { USES_CONVERSION; TCHAR* tstr = OLE2T(bstrVal); if (!tstr) return E_FAIL; #ifdef UNICODE char strTmp[16]; wcstombs(strTmp, (const wchar_t *) tstr, sizeof(strTmp)); (*pdwVal) = strtol(strTmp, 0, iBase); #else (*pdwVal) = strtol(tstr, 0, iBase); #endif SysFreeString(bstrVal); } return hr; }
HRESULT CJSProxyObj::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { if (m_pJSExtender == nullptr) { ATLTRACE(_T("No TangramJSExtender pointer set\r\n")); return S_OK; } HRESULT hr; BSTR bstrMember = NULL; CComBSTR bstrFunction = m_bstrPrefix; bstrMember = m_mapDispId.Lookup(dispIdMember); if (!bstrMember || SysStringLen(bstrMember) == 0) { ATLTRACE(_T("Tangram Could not find DISPID in lookup table\r\n")); return S_OK; } if (m_pEventObj == nullptr) bstrFunction += bstrMember; DISPID dispIdEx; hr = m_pJSExtender->m_pJSEngine->GetDispID(bstrFunction, fdexNameCaseSensitive, &dispIdEx); if (FAILED(hr)) { ATLTRACE(_T("Tangram Could not find matching function '%s' in Tangram\r\n"), OLE2T(bstrFunction)); return S_OK; } m_pJSExtender->m_pJSEngine->InvokeEx(dispIdEx, lcid, DISPATCH_METHOD, pDispParams, pVarResult, pExcepInfo, NULL); return S_OK; }
CCOMString operator+(BSTR bstrStr, CCOMString& strSrc) { USES_CONVERSION; CCOMString s; s.ConcatCopy(OLE2T(bstrStr), (LPCTSTR) strSrc); return s; }
CCOMString operator+(CCOMString& strSrc, BSTR bstrStr) { USES_CONVERSION; CCOMString s; s.ConcatCopy((LPCTSTR) strSrc, OLE2T(bstrStr)); return s; }
STDMETHODIMP CLibObject::ExistsFile( /*[in, string]*/BSTR sPOUName, /*[in, string]*/BSTR sTargetType, /*[in, string]*/BSTR sFileName, /*[full][out] */DWORD* plFileByteSize ) { USES_CONVERSION; HRESULT hr; FC_ARSTAT ret; FC_CArDir* pPOU; FC_CArFile* pFile; if(plFileByteSize) *plFileByteSize = 0; hr = getPouDir(sPOUName, sTargetType, &pPOU, NULL, false); if(hr != S_OK) return hr; if((ret = pPOU->getFile(OLE2T(sFileName), &pFile)) != FC_AR_OK) return onArError(ret, NULL); if(!pFile) return S_FALSE; if(plFileByteSize) { *plFileByteSize = pFile->getSize(); assert(*plFileByteSize>=0); } return S_OK; }
STDMETHODIMP CLibObject::GetFileRaw( /*[in, string]*/ BSTR sPOUName, /*[in, string]*/ BSTR sTargetType, /*[in, string]*/ BSTR sFileName, /*[out,ptr] */ byte* pBytes, /*[in] */ DWORD nBytes ) { USES_CONVERSION; HRESULT hr; FC_ARSTAT ret; FC_CArDir* pPOU; FC_CArFile* pFile; hr = getPouDir(sPOUName, sTargetType, &pPOU, NULL, false); if(hr!=S_OK) //return S_FALSE if POU or file does not exits return hr; //assert: S_OK: POU must exist assert(pPOU); if((ret = pPOU->getFile(OLE2T(sFileName), &pFile)) != FC_AR_OK) return onArError(ret, NULL); if(!pFile) return S_FALSE; if((ret = pFile->getData(nBytes, pBytes)) != FC_AR_OK) return onArError(ret, NULL); return S_OK; }
DWORD AFXAPI _AfxOleGetLenFilePrefixOfMoniker(LPMONIKER lpmk) { USES_CONVERSION; if (lpmk == NULL) return 0; DWORD nLen = 0; LPMONIKER lpmkFirst = _AfxOleGetFirstMoniker(lpmk); if (lpmkFirst != NULL) { DWORD dwMksys; if (lpmkFirst->IsSystemMoniker(&dwMksys) == S_OK && dwMksys == MKSYS_FILEMONIKER) { LPBC lpbc = NULL; SCODE sc = CreateBindCtx(0, &lpbc); if (sc == S_OK) { LPOLESTR lpw = NULL; sc = lpmkFirst->GetDisplayName(lpbc, NULL, &lpw); LPTSTR lpsz = OLE2T(lpw); if (sc == S_OK && lpsz != NULL) { nLen = lstrlen(lpsz); CoTaskMemFree(lpw); } RELEASE(lpbc); } } RELEASE(lpmkFirst); } return nLen; }
STDMETHODIMP CLibObject::PutFileRaw( /*[in, string]*/ BSTR sPOUName, /*[in, string]*/ BSTR sTargetType, /*[in, string]*/ BSTR sFileName, /*[in, ptr]*/ BYTE* pBytes, /*[in, ptr]*/ DWORD nBytes ) { USES_CONVERSION; HRESULT hr; FC_ARSTAT ret; FC_CArDir* pPOU; if(!m_ar.isOpenWrite()) return E_ACCESSDENIED; hr = getPouDir(sPOUName, sTargetType, &pPOU, NULL, true); if(hr != S_OK) { assert(hr != S_FALSE); return hr; } ret = pPOU->createFileFromMem(OLE2T(sFileName), nBytes, pBytes); return ret==FC_AR_OK ? S_OK : onArError(ret, NULL); }
// FindString --------------------------------------------------------------- STDMETHODIMP CICodeList::FindString( BSTR strFind, VARIANT bAcceptPartial, long* plItemIndex ) { ASSERT( m_pCtrl != NULL && ::IsWindow( m_pCtrl->m_hWnd ) ); if( !::IsWindow( m_pCtrl->GetSafeHwnd() ) ) return E_POINTER; CHECK_PTR( plItemIndex ); BOOL bPartial = TRUE; // bAcceptPartial flag is optional... if( !IS_VT_EMPTY( bAcceptPartial ) ) { HRESULT hR = ::VariantChangeType( &bAcceptPartial, &bAcceptPartial, 0, VT_BOOL ); if( SUCCEEDED( hR ) ) bPartial = ( VARIANT_FALSE != bAcceptPartial.boolVal ); } // Convert string USES_CONVERSION; *plItemIndex = m_pCtrl->FindString( OLE2T( strFind ), bPartial ); return S_OK; }
STDMETHODIMP CLibObject::DeleteFiles( /*[in, string]*/ BSTR sPOUName, /*[in, string]*/ BSTR sTargetType, /*[in, string]*/ BSTR sFileSpec ) { USES_CONVERSION; HRESULT hr; FC_ARSTAT ret; FC_CArDir* pDir; hr = getPouDir(sPOUName, sTargetType, &pDir, NULL, false); if(hr != S_OK && hr!=S_FALSE) return hr;//must be fatal error.. if(!pDir) return S_OK;//retutn S_OK if POU does not exists if(sFileSpec) { ret = pDir->remove(OLE2T(sFileSpec), NULL); } else { FC_CStr dirname(pDir->getName()); pDir = pDir->getParent(); assert(pDir); ret = pDir->remove(dirname, NULL); } return ret==FC_AR_OK ? S_OK : onArError(ret, NULL); }
CString CPdbHelper::GetImageID(HMODULE hModule) { WCHAR wszFileName[MAX_PATH] = {0}; GetModuleFileNameW( hModule, wszFileName, MAX_PATH); SYMSRV_INDEX_INFO tIndexInfo = {0}; tIndexInfo.sizeofstruct = sizeof(tIndexInfo); BOOL bRet = s_pfnSymSrvGetFileIndexInfoW( wszFileName, &tIndexInfo, 0); CString strGuid; if( bRet ) { LPOLESTR pGuid; HRESULT hr = StringFromCLSID( tIndexInfo.guid, &pGuid); if( SUCCEEDED(hr) ) { USES_CONVERSION; strGuid.Format( _T("%s"), OLE2T(pGuid)); CoTaskMemFree(pGuid); strGuid.Replace( _T("{"), _T("")); strGuid.Replace( _T("}"), _T("")); strGuid.Replace( _T("-"), _T("")); strGuid.AppendFormat(_T("%X"), tIndexInfo.age); } } return strGuid; }
/** * Gets value of specified attribute out of some HTML Tag * @param pElem HTML element pointer * @param bstrText Name of the attribute * @param sValue Reference of the string that will hold the value * @return true if attribute is present false otherwise */ bool COfflineBrowser::GetAttribute(MSHTML::IHTMLElementPtr pElem, BSTR bstrText, std::string& sValue) { try { CComVariant var = pElem->getAttribute(bstrText, 0); USES_CONVERSION; if (var.vt == VT_BSTR && var.bstrVal != NULL) sValue = (LPCTSTR)OLE2T(var.bstrVal); else sValue = ""; } //Attribute not present catch (_com_error e) { sValue = ""; } //Special condition for about:blank, keep remember it int nIndex = sValue.find("about:blank"); if(nIndex == 0) { int nLen = strlen("about:blank"); sValue = sValue.substr(nLen, sValue.length()-nLen); } return sValue.length() ? true : false; }