void SetClipboardText(const std::wstring& text) { if (!::OpenClipboard(::GetDesktopWindow())) return; ATLVERIFY(::EmptyClipboard()); const size_t length = (text.size() + 1) * sizeof(text[0]); HANDLE hmem = ::GlobalAlloc(GMEM_MOVEABLE, length); UIETWASSERT(hmem); // We are not hardened against OOM. void* const ptr = ::GlobalLock(hmem); UIETWASSERT(ptr != NULL); wcscpy_s(static_cast<wchar_t*>(ptr), (text.size() + 1), text.c_str()); UnlockGlobalMemory(hmem); if (::SetClipboardData(CF_UNICODETEXT, hmem) == NULL) { ATLVERIFY(!::GlobalFree(hmem)); ATLVERIFY(::CloseClipboard()); return; } ATLVERIFY(::CloseClipboard()); }
STDMETHODIMP CNdasUnitImpl::GetRaidSimpleStatus ( NDAS_LOGICALUNIT_DEFINITION *NdasLogicalUnitDefinition, UINT8 *NdasUnitNo, DWORD *RaidSimpleStatusFlags ) { HRESULT hr; HNDAS ndasHandle; ATLVERIFY( RaidSimpleStatusFlags != NULL ); hr = ConnectUnitDevice(&ndasHandle); if (FAILED(hr)) { return hr; } hr = NdasVsmGetRaidSimpleStatus( ndasHandle, NdasLogicalUnitDefinition, NdasUnitNo, RaidSimpleStatusFlags ); if (FAILED(hr)) { ATLVERIFY(S_OK == DisonnectUnitDevice(ndasHandle)); return hr; } ATLVERIFY(S_OK == DisonnectUnitDevice(ndasHandle)); return S_OK; }
DWORD CNdasDevicePropGeneralPage::pUpdateThreadStart(DWORD UnitIndex) { ATLASSERT(UnitIndex < RTL_NUMBER_OF(m_pUnitDevices)); if (UnitIndex >= RTL_NUMBER_OF(m_pUnitDevices)) { ATLVERIFY(PostMessage( WM_THREADED_WORK_COMPLETED, 0, static_cast<LPARAM>(UnitIndex))); return 255; } ndas::UnitDevicePtr pUnitDevice = m_pUnitDevices[UnitIndex]; if (!pUnitDevice) { ATLVERIFY(PostMessage( WM_THREADED_WORK_COMPLETED, 0, static_cast<LPARAM>(UnitIndex))); return 1; } (void) pUnitDevice->UpdateHostStats(); ATLVERIFY(PostMessage( WM_THREADED_WORK_COMPLETED, 0, static_cast<LPARAM>(UnitIndex))); return 0; }
HRESULT CCurrencyConversionSamplePlugin::StartDisplayingItems() { CComQIPtr<IGoogleDesktopDisplayPluginHelper> helper(m_pluginHelper); if (m_pluginHelper == NULL) return E_FAIL; // set flags GoogleDesktopDisplayPluginFlags plugin_flags = GDD_PLUGIN_FLAG_NONE; GoogleDesktopDisplayContentFlags content_flags = GDD_CONTENT_FLAG_NONE; ATLVERIFY(SUCCEEDED(helper->SetFlags(plugin_flags, content_flags))); // set about text CComBSTR about_text; about_text.LoadString(IDS_COPYRIGHT); ATLVERIFY(SUCCEEDED(helper->put_about_text(about_text))); // set icons CComPtr<IPicture> title_icon, about_icon; ATLVERIFY(SUCCEEDED(::LoadPictureFromResource(ghInstance, MAKEINTRESOURCE(IDR_GIF_CURRENCY_ICON_SMALL), L"GIF", &title_icon))); ATLVERIFY(SUCCEEDED(::LoadPictureFromResource(ghInstance, MAKEINTRESOURCE(IDR_GIF_CURRENCY_ICON_LARGE), L"GIF", &about_icon))); ATLVERIFY(SUCCEEDED(helper->SetIcons(title_icon, about_icon))); UpdateTitle(false); // display the first set of items SetContentLayout(); ChangeItems(NULL); return S_OK; }
CNBNdasDevice::CNBNdasDevice(PNDASUSER_DEVICE_ENUM_ENTRY pBaseInfo, NDAS_DEVICE_STATUS status) { ATLASSERT(pBaseInfo); CopyMemory(&m_BaseInfo, pBaseInfo, sizeof(NDASUSER_DEVICE_ENUM_ENTRY)); m_status = status; ATLVERIFY(SUCCEEDED( StringCchCopy( m_NdasId.Id, RTL_NUMBER_OF(m_NdasId.Id), pBaseInfo->szDeviceStringId) )); if (pBaseInfo->GrantedAccess & GENERIC_WRITE) { // We uses the magic write key in case write access is granted. ATLVERIFY(SUCCEEDED( StringCchCopy( m_NdasId.Key, RTL_NUMBER_OF(m_NdasId.Key), _T("*****")) )); } ZeroMemory(&m_DeviceId, sizeof(NDAS_DEVICE_ID)); NdasIdStringToDeviceEx(pBaseInfo->szDeviceStringId, &m_DeviceId, NULL, &m_IdExtData); m_DeviceId.VID = m_IdExtData.VID; #if 0 NDASUSER_DEVICE_INFORMATION ndasDeviceInfo; ATLVERIFY( NdasQueryDeviceInformation(pBaseInfo->SlotNo, &ndasDeviceInfo) ); m_DeviceId = ndasDeviceInfo.HardwareInfo.NdasDeviceId; #endif if (m_DeviceId.VID == 0) { ATLTRACE(_T("Assume VID is 1 if VID=0\n")); m_DeviceId.VID = 1; } ATLTRACE(_T("new CNBNdasDevice(%p) : Name %s, ID %s, Slot %d, Access %08x\n"), this, pBaseInfo->szDeviceName, pBaseInfo->szDeviceStringId, pBaseInfo->SlotNo, pBaseInfo->GrantedAccess); }
HRESULT CExeModule::LoadExchangeCodes() { ATLVERIFY(SUCCEEDED(_LoadExchangeCodes(STOCKEXCHANGECODES_SETTINGS, m_StockExchangeCodes))); ATLVERIFY(SUCCEEDED(_LoadExchangeCodes(OPTIONEXCHANGECODES_SETTINGS, m_OptionExchangeCodes))); return S_OK; }
DWORD CDismountDialog::WorkItemStart() { m_EjectError = 0; BOOL success = m_pLogDevice->Eject(&m_EjectParam); if (!success) { m_EjectError = GetLastError(); ATLTRACE("Eject failed, error=0x%X\n", m_EjectError); } else { if (m_EjectParam.ConfigRet != CR_SUCCESS) { ATLTRACE("Eject failed from configuration manager, configRet=%d\n", m_EjectParam.ConfigRet); ATLTRACE("VetoType=%d,VetoName=%ls\n", m_EjectParam.VetoType, m_EjectParam.VetoName); } } ATLVERIFY( PostMessage(WM_WORKITEM_COMPLETED) ); ATLVERIFY( SetEvent(m_WorkItemFinished) ); return 0; }
BOOL CPnpEventConsumerWindow::OnDeviceChange( UINT EventType, PDEV_BROADCAST_HANDLE Dbch) { switch (EventType) { case DBT_DEVICEREMOVECOMPLETE: { ATLVERIFY( m_DevNotifyHandles.Remove(Dbch->dbch_hdevnotify) ); printf("Unregistering DevNotifyHandle=%p\n", Dbch->dbch_hdevnotify); ATLVERIFY( UnregisterDeviceNotification(Dbch->dbch_hdevnotify) ); } break; case DBT_CUSTOMEVENT: if (IsEqualGUID(Dbch->dbch_eventguid, GUID_NDASPORT_PNP_NOTIFICATION)) { PNDASPORT_PNP_NOTIFICATION ndasportNotification = reinterpret_cast<PNDASPORT_PNP_NOTIFICATION>(Dbch->dbch_data); OnNdasPortEvent(ndasportNotification); } else if (IsEqualGUID(Dbch->dbch_eventguid, GUID_NDAS_ATA_LINK_EVENT)) { PNDAS_ATA_LINK_EVENT ndasAtaLinkEvent = reinterpret_cast<PNDAS_ATA_LINK_EVENT>(Dbch->dbch_data); OnNdasAtaLinkEvent(ndasAtaLinkEvent); } else if (IsEqualGUID(Dbch->dbch_eventguid, NDAS_DLU_EVENT_GUID)) { PNDAS_DLU_EVENT ndasDluEvent = reinterpret_cast<PNDAS_DLU_EVENT>(Dbch->dbch_data); OnNdasDluEvent(ndasDluEvent); } else if (IsEqualGUID(Dbch->dbch_eventguid, GUID_IO_VOLUME_MOUNT)) { // printf("Volume is mounted, handle=%p\n", Dbch->dbch_handle); } else { OLECHAR guidString[64] = {0}; StringFromGUID2( Dbch->dbch_eventguid, guidString, 64); if (-1 != Dbch->dbch_nameoffset) { printf("Unknown %s (%ls)", ((PUCHAR)Dbch) + Dbch->dbch_nameoffset, guidString); } else { printf("Unknown %ls", guidString); } } } return TRUE; }
void SetRegistryDWORD(const HKEY root, const std::wstring& subkey, const std::wstring& valueName, const DWORD value) { HKEY key; if (::RegOpenKeyExW(root, subkey.c_str(), 0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS) return; ATLVERIFY(ERROR_SUCCESS == ::RegSetValueExW(key, valueName.c_str(), 0, REG_DWORD, reinterpret_cast<const BYTE*>(&value), sizeof(value))); ATLVERIFY(::RegCloseKey(key) == ERROR_SUCCESS); }
void CMainFrame::OnNdasServiceConnectFailed() { ATLTRACE("Connection to the NDAS Service failed.\n"); ATLVERIFY(m_taskbarIcon.ChangeIcon(_CreateTaskbarIcon(false))); ATLVERIFY( m_taskbarIcon.SetToolTipText(IDR_TASKBAR_FAIL) ); }
void CMainFrame::OnNdasServiceTerminating() { ATLTRACE("NDAS Service is terminating.\n"); ATLVERIFY(m_taskbarIcon.ChangeIcon(_CreateTaskbarIcon(false))); ATLVERIFY(m_taskbarIcon.SetToolTipText(IDR_TASKBAR_FAIL)); }
LRESULT CMiniPieFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { CAppInfo info; // Full screen mode delayed restoration bool bFull = false; info.Restore(bFull, L"Full"); if (bFull) PostMessage(WM_COMMAND, ID_VIEW_FULLSCREEN); CreateSimpleCEMenuBar(); #ifdef WIN32_PLATFORM_WFSP // SmartPhone AtlActivateBackKey(m_hWndCECommandBar); #endif UIAddToolBar(m_hWndCECommandBar); SetCommandButton(ID_APP_EXIT); // StatusBar state restoration bool bVisible = true; info.Restore(bVisible, L"Status"); DWORD dwStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_TOP; if (bVisible) dwStyle |= WS_VISIBLE; // StatusBar creation CreateSimpleStatusBar(ATL_IDS_IDLEMESSAGE, dwStyle); UIAddStatusBar(m_hWndStatusBar); UISetCheck(ID_VIEW_STATUS_BAR, bVisible); // Browser view creation m_hWndClient = m_browser.Create(m_hWnd, NULL, _T("Microsoft.PIEDocView"), WS_CHILD | WS_VISIBLE | WS_BORDER, 0, ID_BROWSER); ATLVERIFY(SUCCEEDED(m_browser.QueryControl(&m_spIWebBrowser2))); ATLVERIFY(SUCCEEDED(AtlAdviseSinkMap(this, true))); // Navigation menu initialization UIEnable(IDM_BACK, FALSE); UIEnable(IDM_FORWARD, FALSE); UIEnable(IDM_STOP, FALSE); UIEnable(IDM_REFRESH, FALSE); #ifdef WIN32_PLATFORM_PSPC // PPC Address bar state restoration VARIANT_BOOL vb = ATL_VARIANT_TRUE; info.Restore(vb, L"Address"); m_spIWebBrowser2->put_AddressBar(vb); UISetCheck(ID_VIEW_ADDRESSBAR, vb == ATL_VARIANT_TRUE); #endif // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); return 0; }
HRESULT RegisterWithGDEventFramework() { CComPtr<IGoogleDesktopRegistrar> registrar; HRESULT hr = registrar.CoCreateInstance(L"GoogleDesktop.Registrar"); if (SUCCEEDED(hr)) { CComBSTR our_guid(CONSOLE_PLUGIN_GUID); WCHAR icon_path[_MAX_PATH + 1] = {0}; ATLVERIFY(::GetModuleFileNameW(NULL, icon_path, _MAX_PATH - 2) != 0); SafeStrCat(icon_path, L"@0", _MAX_PATH+1); CComSafeArray<VARIANT> description; ATLVERIFY(SUCCEEDED(description.Create(8))); VARIANT* props = reinterpret_cast<VARIANT*>(description.m_psa->pvData); for (DWORD i = 0; i < description.GetCount(); ++i) { props[i].vt = VT_BSTR; } props[0].bstrVal = ::SysAllocString(L"Title"); props[1].bstrVal = ::SysAllocString(L"Console Events"); props[2].bstrVal = ::SysAllocString(L"Description"); props[3].bstrVal = ::SysAllocString(L"Outputs events from Google Desktop to the console"); props[4].bstrVal = ::SysAllocString(L"Icon"); props[5].bstrVal = ::SysAllocString(icon_path); props[6].bstrVal = ::SysAllocString(L"Homepage"); props[7].bstrVal = ::SysAllocString(L"http://desktop.google.com"); VARIANT desc; desc.vt = VT_ARRAY | VT_VARIANT; desc.parray = description; hr = registrar->StartComponentRegistration(our_guid, desc); if (SUCCEEDED(hr)) { CComPtr<IUnknown> unknown; hr = registrar->GetRegistrationInterface(CComBSTR(L"GoogleDesktop.EventRegistration"), &unknown); ATLASSERT(SUCCEEDED(hr)); CComQIPtr<IGoogleDesktopRegisterEventPlugin> event_registration(unknown); if (event_registration != NULL) { long cookie = 0; hr = event_registration->RegisterPlugin(our_guid, &cookie); if (SUCCEEDED(hr)) { hr = registrar->FinishComponentRegistration(); if (SUCCEEDED(hr)) { hr = StoreRegistrationCookie(cookie); } } } } } return hr; }
void CNdasDevicePropGeneralPage::OnReset() { ATLTRACE(__FUNCTION__ "\n"); ATLVERIFY(AtlWaitWithMessageLoop(m_ThreadCompleted)); ATLVERIFY(m_imageList.Destroy()); ATLVERIFY(DestroyAcceleratorTable(m_hAccel)); }
void CMainFrame::OnNdasServiceConnectConnected() { ATLTRACE("NDAS Service connection established.\n"); ATLVERIFY(m_taskbarIcon.ChangeIcon(_CreateTaskbarIcon())); ATLVERIFY(m_taskbarIcon.SetToolTipText(IDR_TASKBAR)); m_fPendingUpdateDeviceList = TRUE; m_fPendingUpdateMenuItem = TRUE; }
STDMETHODIMP SysMonPluginPropPage::Apply(void) { int refresh_interval = GetDlgItemInt(IDC_EDIT_REFRESH_INTERVAL, NULL, 0); int max_disk_rw = GetDlgItemInt(IDC_EDIT_MAX_DISK_RW, NULL, 0); int max_net_io = GetDlgItemInt(IDC_EDIT_MAX_NET_IO, NULL, 0); int active_monitors = 0; int auto_adjust_chart_max = 1; if (!refresh_interval) { refresh_interval = 1; // Minimum 1 seconds } if (!max_disk_rw) { max_disk_rw = 50000; } if (!max_net_io) { max_net_io = 50000; } if (::SendMessage(GetDlgItem(IDC_CHECK_CPU), BM_GETCHECK, 0, 0) == BST_CHECKED) { active_monitors |= ACTIVE_MON_CPU; } if (::SendMessage(GetDlgItem(IDC_CHECK_MEM), BM_GETCHECK, 0, 0) == BST_CHECKED) { active_monitors |= ACTIVE_MON_MEM; } if (::SendMessage(GetDlgItem(IDC_CHECK_DISK), BM_GETCHECK, 0, 0) == BST_CHECKED) { active_monitors |= ACTIVE_MON_DISK; } if (::SendMessage(GetDlgItem(IDC_CHECK_NET), BM_GETCHECK, 0, 0) == BST_CHECKED) { active_monitors |= ACTIVE_MON_NET; } auto_adjust_chart_max = (::SendMessage(GetDlgItem(IDC_CHECK_AUTO_MAX), BM_GETCHECK, 0, 0) == BST_CHECKED); for (int i = 0; i < static_cast<int>(m_nObjects); ++i) { CComQIPtr<IGoogleDesktopSysMonPlugin> plugin(m_ppUnk[i]); if (plugin) { ATLVERIFY(SUCCEEDED(plugin->put_refresh_interval(refresh_interval))); ATLVERIFY(SUCCEEDED(plugin->put_active_monitors(active_monitors))); ATLVERIFY(SUCCEEDED(plugin->put_max_disk_rw_in_chart(max_disk_rw))); ATLVERIFY(SUCCEEDED(plugin->put_max_net_io_in_chart(max_net_io))); ATLVERIFY(SUCCEEDED(plugin->put_auto_adjust_chart_max( auto_adjust_chart_max))); } } m_bDirty = FALSE; return S_OK; }
void CMainFrame::pChangeTaskBarIcon(bool Normal) { if (Normal) { ATLVERIFY( m_taskbarIcon.ChangeIcon(pCreateTaskbarIcon(true)) ); ATLVERIFY( m_taskbarIcon.SetToolTipText(IDR_TASKBAR) ); } else { ATLVERIFY( m_taskbarIcon.ChangeIcon(pCreateTaskbarIcon(false)) ); ATLVERIFY( m_taskbarIcon.SetToolTipText(IDR_TASKBAR_FAIL) ); } }
void CMainFrame::pImportRegistration(LPCTSTR szFileName) { DWORD count = 0; NDAS_NIF_V1_ENTRY* pEntry; HRESULT hr = ::NdasNifImport(szFileName, &count, &pEntry); if (SUCCEEDED(hr)) { NifEntryArray entryArray; for (DWORD i = 0; i < count; ++i) { ATLTRACE(_T("%d/%d: %s\n"), i+1, count, pEntry->Name); entryArray.Add(NifEntry(pEntry[i])); } if (NULL == m_wndImportDlg.m_hWnd) { ATLVERIFY(m_wndImportDlg.Create(m_hWnd, PtrToUlong(&entryArray))); m_wndImportDlg.CenterWindow(::GetDesktopWindow()); m_wndImportDlg.ShowWindow(SW_SHOWNORMAL); } else { m_wndImportDlg.AddNifEntry(entryArray); m_wndImportDlg.SetActiveWindow(); } ATLVERIFY(NULL == ::LocalFree(pEntry)); } else { ATLTRACE("NdasNifImport Error hr=%x\n", hr); CString strError; TCHAR szCompactPath[50]; LPCTSTR lpFileName; if (::PathCompactPathEx(szCompactPath, szFileName, 50, 0)) { lpFileName = szCompactPath; } else { lpFileName = szFileName; } strError.FormatMessage(IDS_ERROR_IMPORT_FMT, lpFileName); ErrorMessageBox(static_cast<LPCTSTR>(strError), IDS_MAIN_TITLE, hr); } }
// Worker Thread Start Routine DWORD CDeviceGeneralPage::OnWorkerThreadStart(LPVOID lpParameter) { UINT i = PtrToUlong(lpParameter); ATLASSERT(i < RTL_NUMBER_OF(m_pUnitDevices)); if (i >= RTL_NUMBER_OF(m_pUnitDevices)) { return 255; } ndas::UnitDevicePtr pUnitDevice = m_pUnitDevices[i]; if (NULL == pUnitDevice.get()) { return 1; } (void) pUnitDevice->UpdateHostStats(); if (::IsWindow(m_hWnd)) { ATLVERIFY(PostMessage(WM_USER_DONE, 0, static_cast<LPARAM>(i))); } return 0; }
inline BYTE IStream::ReadByte() { BYTE b; DWORD dwBytesRead = 0; ATLVERIFY(true == Read(&b, 1, dwBytesRead) && 1 == dwBytesRead); return b; }
double HighResolutionTimer::TotalElapsed() const throw() { LARGE_INTEGER lCountNow = {0}; ATLVERIFY(TRUE == ::QueryPerformanceCounter(&lCountNow)); return static_cast<double>(m_lTotalElapsed.QuadPart + (m_bStarted ? (lCountNow.QuadPart-m_lCountStart.QuadPart) : 0LL)) / GetPerformanceFrequency(); }
bool CFotoEntity::findAt(int nX, int nY){ int nR, nL = nX; ATLVERIFY( addLine(nY, nL, nR) ); CRanges r; r.push_back( tagUShorts(nL, nR) ); m_mapRanges[nY] = r; findAtNextLine<-1>(nY-1, nL, nR); findAtNextLine<1>(nY+1, nL, nR); int nAdded; do{ nAdded = 0; for(std::map<int, CRanges>::iterator it = m_mapRanges.begin(); it != m_mapRanges.end(); it++){ CRanges& r = it->second; if (r.IsFlag(1|2) == (1|2)) continue; int nUp = 0, nDown = 0; for(size_t i=0; i < r.size(); i++){ if (!r.IsFlag(1)) nUp += findAtNextLine<-1>(it->first - 1, r[i].m_us1, r[i].m_us2); if (!r.IsFlag(2)) nDown += findAtNextLine<1>(it->first + 1, r[i].m_us1, r[i].m_us2); } int nFlag = nUp ? 0 : 1; if (!nDown) nFlag |= 2; if (nFlag) r.AddFlag( nFlag ); nAdded += nUp + nDown; } }while(nAdded); return true; }
int WINAPI _tWinMain( HINSTANCE hInst, HINSTANCE, LPTSTR, int ) { _tsetlocale( LC_ALL, _T(".OCP") ); ATLVERIFY( SUCCEEDED( _Module.Init( NULL, hInst ) ) ); if( !EnableDebugPrivilege() ) { MessageBoxV( NULL, IDS_NO_DEBUG_PRIVILEGE, MB_OK | MB_ICONHAND ); return 0; } InitializeCriticalSection( &g_cs ); LoadInternalExceptionList(); LoadSettings(); DumpInit(); if( !ProcessCommandLine() ) { AtlInitCommonControls( ICC_BAR_CLASSES ); LoadLibrary( CRichEditCtrl::GetLibraryName() ); CMainDlg dlgMain; g_pMainWnd = &dlgMain; int nRet = dlgMain.DoModal(); g_pMainWnd = NULL; } DumpUninit(); SaveSettings(); DeleteCriticalSection( &g_cs ); _Module.Term(); return 0; }
STDMETHODIMP CCurrencyConversionSamplePluginContentItem::OpenItem() { CComBSTR heading; CComQIPtr<IGoogleDesktopDisplayContentItemHelper> helper(m_contentItemHelper); ATLVERIFY(SUCCEEDED(helper->get_heading(&heading))); MessageBox(NULL, heading, _T("Currency Exchange Rate"), MB_OK); return S_OK; }
LRESULT MsgOnlyWindow::OnInitPlugin(UINT, WPARAM, LPARAM, BOOL& bHandled) { bHandled = true; m_plugin->InitFromSavedLastCurrencies(); HRESULT hr = m_plugin->StartDisplayingItems(); ATLVERIFY(SUCCEEDED(hr)); return 0; }
HRESULT CSwapAPODllModule::DllRegisterServer(BOOL bRegTypeLib) throw() { HRESULT hResult; UINT32 u32APORegIndex = 0; UINT32 u32APOUnregIndex = 0; // Register all APOs implemented in this module. for (u32APORegIndex = 0; u32APORegIndex < SIZEOF_ARRAY(gCoreAPOs); u32APORegIndex++) { hResult = RegisterAPO(gCoreAPOs[u32APORegIndex]); if (FAILED(hResult)) { goto ExitFailed; } } // Register the module. hResult = CAtlDllModuleT<CSwapAPODllModule>::DllRegisterServer(bRegTypeLib); if (FAILED(hResult)) { goto ExitFailed; } return hResult; ExitFailed: // Unregister all registered APOs if something failed. for (u32APOUnregIndex = 0; u32APOUnregIndex < u32APORegIndex; u32APOUnregIndex++) { ATLVERIFY(SUCCEEDED(UnregisterAPO(gCoreAPOs[u32APOUnregIndex]->clsid))); } return hResult; } // DllRegisterServer
CDatabase *CCachedDBConnections::GetConnection(const CString &strConnect, BOOL bAutoOpen) { CCacheMap::CPair *pKeyValPair = m_DBCache.PLookup(strConnect); CDatabase *pDB = NULL; if (pKeyValPair != NULL) { pDB = pKeyValPair->value; } if (NULL == pDB) { try { pDB = new CDatabase; } catch (...) { pDB = NULL; } } if (pDB != NULL && !pDB->IsOpen() && bAutoOpen) { ATLVERIFY(pDB->OpenEx(strConnect, CDatabase::useCursorLib | CDatabase::noOdbcDialog)); } if (NULL == pKeyValPair) { m_DBCache[strConnect] = pDB; } return pDB; }
static HMODULE WINAPI HookLoadLibraryW(PCWSTR lpLibFileName) { PCWSTR pwzName = wcsrchr(lpLibFileName, L'\\'); if (NULL != pwzName) ++pwzName; else pwzName = lpLibFileName; static const PCWSTR pwzDlls[] = { L"jsdbgui.dll", L"jsprofilerui.dll", L"networkinspection.dll" }; for (size_t i = 0; i < ARRAYSIZE(pwzDlls); ++i) { if (0 == _wcsicmp(pwzName, pwzDlls[i])) { static WCHAR wzIEPath[MAX_PATH] = { 0 }; if (L'\0' == wzIEPath[0]) { CStaticDataInitCriticalSectionLock lock; ATLVERIFY(SUCCEEDED(lock.Lock())); if (L'\0' == wzIEPath[0]) { HMODULE hDT = GetModuleHandle(_T("iedvtool.dll")); ATLASSERT(NULL != hDT); GetModuleFileName(hDT, wzIEPath, MAX_PATH); *(wcsrchr(wzIEPath, L'\\') + 1) = L'\0'; } lock.Unlock(); } wstring wsDll(wzIEPath); wsDll.append(pwzName); return RawLoadLibraryW(wsDll.c_str()); } } return RawLoadLibraryW(lpLibFileName); }
std::vector<std::wstring> GetFileList(const std::wstring& pattern, const bool fullPaths) { const std::wstring directory = (fullPaths ? GetDirPart(pattern) : L""); // may not pass an empty string to FindFirstFileEx UIETWASSERT(pattern.length() > 0); // string passed to FindFirstFileEx must not end in a backslash UIETWASSERT(pattern.back() != L'\\'); WIN32_FIND_DATA findData; HANDLE hFindFile = ::FindFirstFileExW(pattern.c_str(), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0); std::vector<std::wstring> result; if (hFindFile == INVALID_HANDLE_VALUE) { // If there are NO matching files, then FindFirstFileExW returns // INVALID_HANDLE_VALUE and the last error is ERROR_FILE_NOT_FOUND. UIETWASSERT(::GetLastError() == ERROR_FILE_NOT_FOUND); return result; } do { result.emplace_back(directory + findData.cFileName); } while (::FindNextFileW(hFindFile, &findData)); UIETWASSERT(::GetLastError() == ERROR_NO_MORE_FILES); ATLVERIFY(::FindClose(hFindFile)); return result; }
void CreateRegistryKey(const HKEY root, const std::wstring& subkey, const std::wstring& newKey) { HKEY key; if (::RegOpenKeyExW(root, subkey.c_str(), 0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS) return; HKEY resultKey; // TODO: RegCreateKey is deprecated. const LONG createResult = ::RegCreateKeyW(key, newKey.c_str(), &resultKey); UIETWASSERT(createResult == ERROR_SUCCESS); if (createResult == ERROR_SUCCESS) { ATLVERIFY(::RegCloseKey(resultKey) == ERROR_SUCCESS); } ATLVERIFY(::RegCloseKey(key) == ERROR_SUCCESS); }