本文整理汇总了C++中FAILED_UNEXPECTEDLY函数的典型用法代码示例。如果您正苦于以下问题:C++ FAILED_UNEXPECTEDLY函数的具体用法?C++ FAILED_UNEXPECTEDLY怎么用?C++ FAILED_UNEXPECTEDLY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FAILED_UNEXPECTEDLY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SHSetStrRet
HRESULT WINAPI CDesktopFolder::GetDetailsOf(
PCUITEMID_CHILD pidl,
UINT iColumn,
SHELLDETAILS *psd)
{
if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl)
{
psd->fmt = DesktopSFHeader[iColumn].fmt;
psd->cxChar = DesktopSFHeader[iColumn].cxChar;
return SHSetStrRet(&psd->str, DesktopSFHeader[iColumn].colnameid);
}
CComPtr<IShellFolder2> psf;
HRESULT hr = _GetSFFromPidl(pidl, &psf);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
hr = psf->GetDetailsOf(pidl, iColumn, psd);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return hr;
}
示例2: TRACE
// Stop tracking a system popup submenu
HRESULT CMenuFocusManager::PopTrackedPopup(HMENU popup)
{
StackEntryType type;
HMENU hmenu;
HRESULT hr;
TRACE("PopTrackedPopup %p\n", popup);
hr = PopFromArray(&type, NULL, &hmenu);
if (FAILED_UNEXPECTEDLY(hr))
{
UpdateFocus();
return hr;
}
_ASSERT(type == TrackedMenuEntry);
if (type != TrackedMenuEntry)
return E_FAIL;
if (hmenu != popup)
return E_FAIL;
hr = UpdateFocus();
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return S_OK;
}
示例3: CISFBand_CreateInstance
HRESULT CBandSiteMenu::_CreateNewISFBand(HWND hwnd, REFIID riid, void** ppv)
{
WCHAR path[MAX_PATH];
WCHAR message[256];
BROWSEINFOW bi = { hwnd, NULL, path };
if (LoadStringW(GetModuleHandleW(L"browseui.dll"), IDS_BROWSEFORNEWTOOLAR, message, _countof(message)))
bi.lpszTitle = message;
else
bi.lpszTitle = L"Choose a folder";
CComHeapPtr<ITEMIDLIST> pidlSelected;
pidlSelected.Attach(SHBrowseForFolderW(&bi));
if (pidlSelected == NULL)
return S_FALSE;
CComPtr<IShellFolderBand> pISFB;
HRESULT hr = CISFBand_CreateInstance(IID_IShellFolderBand, (PVOID*)&pISFB);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
hr = pISFB->InitializeSFB(NULL, pidlSelected);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return pISFB->QueryInterface(riid, ppv);
}
示例4: IUnknown_QueryService
HRESULT CMenuFocusManager::IsTrackedWindowOrParent(HWND hWnd)
{
for (int i = m_bandCount; --i >= 0;)
{
StackEntry& entry = m_bandStack[i];
if (entry.type != TrackedMenuEntry)
{
HRESULT hr = entry.mb->IsWindowOwner(hWnd);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
if (hr == S_OK)
return S_OK;
if (entry.mb->_IsPopup() == S_OK)
{
CComPtr<IUnknown> site;
CComPtr<IOleWindow> pw;
hr = entry.mb->GetSite(IID_PPV_ARG(IUnknown, &site));
if (FAILED_UNEXPECTEDLY(hr))
continue;
hr = IUnknown_QueryService(site, SID_SMenuBandParent, IID_PPV_ARG(IOleWindow, &pw));
if (FAILED_UNEXPECTEDLY(hr))
continue;
HWND hParent;
if (pw->GetWindow(&hParent) == S_OK && hParent == hWnd)
return S_OK;
}
}
}
return S_FALSE;
}
示例5: CoCreateInstance
HRESULT CComCatCachedCategory::LoadFromComCatMgr()
{
HRESULT hr;
CComPtr<ICatInformation> pCatInformation;
CComPtr<IEnumGUID> pEnumGUID;
ULONG pFetched;
CLSID tmp;
// Get component categories manager instance
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER,
IID_PPV_ARG(ICatInformation, &pCatInformation));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
// Get the proper enumerator
hr = pCatInformation->EnumClassesOfCategories(1, &fCategory, NULL, NULL, &pEnumGUID);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
// Enumerate elements
do
{
pFetched = 0;
pEnumGUID->Next(1, &tmp, &pFetched);
if (pFetched)
{
if (DSA_InsertItem(fLocalDsa, DSA_APPEND, &tmp) == E_OUTOFMEMORY)
return E_OUTOFMEMORY;
}
}
while (pFetched > 0);
return S_OK;
}
示例6: pidl
HRESULT CBandSiteMenu::_AddISFBandToMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, IUnknown* pBand, DWORD dwBandID, UINT *newMenuId)
{
CComPtr<IShellFolderBand> psfb;
HRESULT hr = pBand->QueryInterface(IID_PPV_ARG(IShellFolderBand, &psfb));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
BANDINFOSFB bi = {ISFB_MASK_IDLIST};
hr = psfb->GetBandInfoSFB(&bi);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
CComHeapPtr<ITEMIDLIST> pidl(bi.pidl);
if (!pidl)
{
ERR("Failed to get the pidl of the CISFBand\n");
return E_OUTOFMEMORY;
}
WCHAR buffer[MAX_PATH];
hr = ILGetDisplayNameEx(NULL, pidl, buffer, ILGDN_INFOLDER) ? S_OK : E_FAIL;
if (FAILED_UNEXPECTEDLY(hr))
return hr;
UINT id = idCmdFirst + m_ComCatGuids.GetSize() + FIRST_COMCAT_MENU_ID + dwBandID;
if (id >= idCmdLast)
return E_FAIL;
*newMenuId = id;
InsertMenu(hmenu, indexMenu, MF_BYPOSITION, id, buffer);
return S_OK;
}
示例7: SHOpenFolderAndSelectItems
/***********************************************************************
* SHOpenFolderAndSelectItems
*
* Unimplemented.
*/
EXTERN_C HRESULT
WINAPI
SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder,
UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
DWORD dwFlags)
{
ERR("SHOpenFolderAndSelectItems() is hackplemented\n");
PCIDLIST_ABSOLUTE pidlItem;
if (cidl)
{
/* Firefox sends a full pidl here dispite the fact it is a PCUITEMID_CHILD_ARRAY -_- */
if (ILGetNext(apidl[0]) != NULL)
{
pidlItem = apidl[0];
}
else
{
pidlItem = ILCombine(pidlFolder, apidl[0]);
}
}
else
{
pidlItem = pidlFolder;
}
CComPtr<IShellFolder> psfDesktop;
HRESULT hr = SHGetDesktopFolder(&psfDesktop);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
STRRET strret;
hr = psfDesktop->GetDisplayNameOf(pidlItem, SHGDN_FORPARSING, &strret);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
WCHAR wszBuf[MAX_PATH];
hr = StrRetToBufW(&strret, pidlItem, wszBuf, _countof(wszBuf));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
WCHAR wszParams[MAX_PATH];
wcscpy(wszParams, L"/select,");
wcscat(wszParams, wszBuf);
SHELLEXECUTEINFOW sei;
memset(&sei, 0, sizeof sei);
sei.cbSize = sizeof sei;
sei.fMask = SEE_MASK_WAITFORINPUTIDLE;
sei.lpFile = L"explorer.exe";
sei.lpParameters = wszParams;
if (ShellExecuteExW(&sei))
return S_OK;
else
return E_FAIL;
}
示例8: IUnknown_QueryService
HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
{
ULONG eaten;
ULONG attributes;
HRESULT hr;
HWND topLevelWindow;
CComPtr<IShellBrowser> pisb;
hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &pisb));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
hr = IUnknown_GetWindow(pisb, &topLevelWindow);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
LPWSTR input;
int inputLength = fCombobox.GetWindowTextLength() + 2;
input = new WCHAR[inputLength];
fCombobox.GetWindowText(input, inputLength);
LPWSTR address;
int addressLength = ExpandEnvironmentStrings(input, NULL, 0);
if (addressLength <= 0)
{
address = input;
}
else
{
addressLength += 2;
address = new WCHAR[addressLength];
if (!ExpandEnvironmentStrings(input, address, addressLength))
{
delete[] address;
address = input;
}
}
CComPtr<IShellFolder> psfDesktop;
hr = SHGetDesktopFolder(&psfDesktop);
if (SUCCEEDED(hr))
{
hr = psfDesktop->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlLastParsed, &attributes);
}
if (address != input)
delete [] address;
delete [] input;
return hr;
}
示例9: _ILCreateDesktop
HRESULT WINAPI CDesktopFolder::FinalConstruct()
{
WCHAR szMyPath[MAX_PATH];
HRESULT hr;
/* Create the root pidl */
pidlRoot = _ILCreateDesktop();
if (!pidlRoot)
return E_OUTOFMEMORY;
/* Create the inner fs folder */
hr = SHELL32_CoCreateInitSF(pidlRoot,
NULL,
NULL,
&CLSID_ShellFSFolder,
CSIDL_DESKTOPDIRECTORY,
IID_PPV_ARG(IShellFolder2, &m_DesktopFSFolder));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
/* Create the inner shared fs folder. Dont fail on failure. */
hr = SHELL32_CoCreateInitSF(pidlRoot,
NULL,
NULL,
&CLSID_ShellFSFolder,
CSIDL_COMMON_DESKTOPDIRECTORY,
IID_PPV_ARG(IShellFolder2, &m_SharedDesktopFSFolder));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
/* Create the inner reg folder */
hr = CRegFolder_CreateInstance(&CLSID_ShellDesktop,
pidlRoot,
L"",
IID_PPV_ARG(IShellFolder2, &m_regFolder));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
/* Cache the path to the user desktop directory */
if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE ))
return E_UNEXPECTED;
sPathTarget = (LPWSTR)SHAlloc((wcslen(szMyPath) + 1) * sizeof(WCHAR));
if (!sPathTarget)
return E_OUTOFMEMORY;
wcscpy(sPathTarget, szMyPath);
return S_OK;
}
示例10: SHGetPathFromIDListW
// Code is duplicated in CDefaultContextMenu
HRESULT CNewMenu::CreateNewFolder(LPCMINVOKECOMMANDINFO lpici)
{
WCHAR wszPath[MAX_PATH];
WCHAR wszName[MAX_PATH];
WCHAR wszNewFolder[25];
HRESULT hr;
/* Get folder path */
hr = SHGetPathFromIDListW(m_pidlFolder, wszPath);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
return E_FAIL;
/* Create the name of the new directory */
if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFolder))
return E_FAIL;
/* Create the new directory and show the appropriate dialog in case of error */
if (SHCreateDirectory (lpici->hwnd, wszName) != ERROR_SUCCESS)
return E_FAIL;
/* Show and select the new item in the def view */
SelectNewItem(lpici, SHCNE_MKDIR, SHCNF_PATHW, wszName);
return S_OK;
}
示例11: KillTimer
HRESULT CMenuToolbarBase::OnPopupTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (wParam != TIMERID_HOTTRACK)
{
bHandled = FALSE;
return 0;
}
KillTimer(TIMERID_HOTTRACK);
if (!m_timerEnabled)
return 0;
m_timerEnabled = FALSE;
if (m_hotItem < 0)
return 0;
// Returns S_FALSE if the current item did not show a submenu
HRESULT hr = PopupItem(m_hotItem, FALSE);
if (hr != S_FALSE)
return 0;
// If we didn't switch submenus, cancel the current popup regardless
if (m_popupBar)
{
HRESULT hr = CancelCurrentPopup();
if (FAILED_UNEXPECTEDLY(hr))
return 0;
}
return 0;
}
示例12: SetImageList
HRESULT CMenuToolbarBase::UpdateImageLists()
{
if ((m_initFlags & (SMINIT_TOPLEVEL | SMINIT_VERTICAL)) == SMINIT_TOPLEVEL) // not vertical.
{
// No image list, prevents the buttons from having a margin at the left side
SetImageList(NULL);
return S_OK;
}
// Assign the correct imagelist and padding based on the current icon size
int shiml;
if (m_menuBand->UseBigIcons())
{
shiml = SHIL_LARGE;
SetPadding(4, 0);
}
else
{
shiml = SHIL_SMALL;
SetPadding(4, 4);
}
IImageList * piml;
HRESULT hr = SHGetImageList(shiml, IID_PPV_ARG(IImageList, &piml));
if (FAILED_UNEXPECTEDLY(hr))
{
SetImageList(NULL);
}
else
{
SetImageList((HIMAGELIST)piml);
}
return S_OK;
}
示例13: GetShellFolder
HRESULT CMenuSFToolbar::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
{
HRESULT hr;
hr = m_shellFolder->QueryInterface(riid, ppv);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
if (pdwFlags)
*pdwFlags = m_dwMenuFlags;
if (ppidl)
{
LPITEMIDLIST pidl = NULL;
if (m_idList)
{
pidl = ILClone(m_idList);
if (!pidl)
{
ERR("ILClone failed!\n");
(*reinterpret_cast<IUnknown**>(ppv))->Release();
return E_FAIL;
}
}
*ppidl = pidl;
}
return hr;
}
示例14: GetDataFromId
HRESULT CMenuToolbarBase::PopupItem(INT iItem, BOOL keyInitiated)
{
INT index;
DWORD_PTR dwData;
if (iItem < 0)
return S_OK;
if (m_popupBar == this && m_popupItem == iItem)
return S_OK;
GetDataFromId(iItem, &index, &dwData);
HRESULT hr = InternalHasSubMenu(iItem, index, dwData);
if (hr != S_OK)
return hr;
if (m_popupBar)
{
HRESULT hr = CancelCurrentPopup();
if (FAILED_UNEXPECTEDLY(hr))
return hr;
}
if (!(m_initFlags & SMINIT_VERTICAL))
{
TRACE("PopupItem non-vertical %d %d\n", index, iItem);
m_menuBand->_ChangeHotItem(this, iItem, 0);
}
return InternalPopupItem(iItem, index, dwData, keyInitiated);
}
示例15: while
// Used so that the toolbar can properly ignore mouse events, when the menu is being used with the keyboard
void CMenuFocusManager::DisableMouseTrack(HWND parent, BOOL disableThis)
{
BOOL bDisable = FALSE;
BOOL lastDisable = FALSE;
int i = m_bandCount;
while (--i >= 0)
{
StackEntry& entry = m_bandStack[i];
if (entry.type != TrackedMenuEntry)
{
HWND hwnd;
HRESULT hr = entry.mb->_GetTopLevelWindow(&hwnd);
if (FAILED_UNEXPECTEDLY(hr))
break;
if (hwnd == parent)
{
lastDisable = disableThis;
entry.mb->_DisableMouseTrack(disableThis);
bDisable = TRUE;
}
else
{
lastDisable = bDisable;
entry.mb->_DisableMouseTrack(bDisable);
}
}
}
m_mouseTrackDisabled = lastDisable;
}