/** * Get named GUID for debug log. * Attempt to translate it through standard Registry lookup, or our * custom Registry repository of interface, GUID, Co-class names. */ LPCWSTR DbgGetIID(REFIID riid) { static CComAutoCriticalSection s_lock; CComCritSecLock<CComCriticalSection> lock(s_lock); static CSimpleMap<GUID, CComBSTR> s_Cache; LPCWSTR pwstrResult = s_Cache.Lookup(riid); if( pwstrResult != NULL ) return pwstrResult; TCHAR szName[80] = { 0 }; OLECHAR wszGUID[50] = { 0 }; ::StringFromGUID2(riid, wszGUID, lengthof(wszGUID)); // Attempt to find it in the interfaces section CRegKey key; DWORD dwType = 0; DWORD dwCount = sizeof(szName) - sizeof(TCHAR); key.Open(HKEY_CLASSES_ROOT, _T("Interface"), KEY_READ); if( szName[0] == '\0' && key.Open(key, wszGUID, KEY_READ) == NOERROR ) { ::RegQueryValueEx(key.m_hKey, NULL, NULL, &dwType, (LPBYTE) szName, &dwCount); } // Attempt to find it in the CLSID section key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ); if( szName[0] == '\0' && key.Open(key, wszGUID, KEY_READ) == NOERROR ) { ::RegQueryValueEx(key.m_hKey, NULL, NULL, &dwType, (LPBYTE) szName, &dwCount); } // Attempt to find it in our Named GUIDs section key.Open(HKEY_CLASSES_ROOT, _T("Named GUIDs"), KEY_READ); if( szName[0] == '\0' && key.Open(key, wszGUID, KEY_READ) == NOERROR ) { ::RegQueryValueEx(key.m_hKey, NULL, NULL, &dwType, (LPBYTE) szName, &dwCount); } if( szName[0] == '\0' ) wcscpy_s(szName, lengthof(szName), CW2T(wszGUID)); s_Cache.Add(riid, CComBSTR(szName)); return s_Cache.Lookup(riid); }
/** * Get named PROPERTYKEY for debug log. * Attempt to translate it through standard property system lookup, or our * custom Registry repository of GUIDs. */ LPCWSTR DbgGetPKEY(REFPROPERTYKEY pkey) { static CComAutoCriticalSection s_lock; CComCritSecLock<CComCriticalSection> lock(s_lock); static CSimpleMap< PROPERTYKEY, CComBSTR, CSimpleMapPkeyEqualHelper<PROPERTYKEY, CComBSTR> > s_Cache; LPCWSTR pwstrResult = s_Cache.Lookup(pkey); if( pwstrResult != NULL ) return pwstrResult; WCHAR wszName[80] = { 0 }; // Let Windows tell us the property name CCoTaskString str; if( SUCCEEDED( ::PSGetNameFromPropertyKey(pkey, &str) ) ) wcscpy_s(wszName, lengthof(wszName), str); // Attempt to find it in our Named GUIDs section if( wszName[0] == '\0' ) { WCHAR wszGUID[70] = { 0 }; CRegKey key; DWORD dwType = 0, dwCount = sizeof(wszGUID) - sizeof(TCHAR); key.Open(HKEY_CLASSES_ROOT, _T("Named GUIDs"), KEY_READ); if( key.Open(key, wszGUID, KEY_READ) == NOERROR ) ::RegQueryValueExW(key.m_hKey, NULL, NULL, &dwType, (LPBYTE) wszName, &dwCount); } // Just format the GUID if( wszName[0] == '\0' ) ::PSStringFromPropertyKey(pkey, wszName, lengthof(wszName)); // Add it to cache and return s_Cache.Add(pkey, CComBSTR(wszName)); return s_Cache.Lookup(pkey); }
void CPluginPropertyPage::_GetData() { CSimpleMap<int , CSimpleArray<CString>*> map; for (int nType = PLT_TOOLBAR/*1*/; nType <= PLUGIN_TYPECNT; nType++) { CSimpleArray<CString>*pAry = new CSimpleArray<CString>; map.Add( nType, pAry ); } int nIndex; for (nIndex = 0; nIndex < m_listview.GetItemCount(); nIndex++) { CString strFile; m_listview.GetItemText( nIndex, 0, strFile ); if ( FALSE == m_listview.GetCheckState( nIndex ) ) continue; int nType = int( m_listview.GetItemData( nIndex ) ); CSimpleArray<CString>* pAry = NULL; pAry = map.Lookup( nType ); if (NULL == pAry) continue; pAry->Add( strFile ); } for (nIndex = 0; nIndex < map.GetSize(); nIndex++) { CSimpleArray<CString>*pAry = NULL; pAry = map.GetValueAt( nIndex ); int nType = map.GetKeyAt( nIndex ); CString strKey; strKey.Format( _T("Plugin%02d"), nType ); CIniFileO pr( g_szIniFileName, strKey ); pr.SetValue( pAry->GetSize(), _T("Count") ); for (int nNo = 0; nNo < pAry->GetSize(); nNo++) { strKey.Format(_T("%02d"), nNo); pr.SetString( (*pAry)[nNo], strKey ); } delete pAry; } }
// unhandled exception callback set with SetUnhandledExceptionFilter() int32_t WINAPI CustomUnhandledExceptionFilter(PEXCEPTION_POINTERS pExInfo) { _crashStateMap.Lookup(_getpid())->GenerateErrorReport(pExInfo); return EXCEPTION_EXECUTE_HANDLER; }