예제 #1
0
HRESULT CSDShellExt::QueryContextMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags) {
    if (uFlags & CMF_DEFAULTONLY) {
        return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
    }

    //
    // insert the menu item
    //
    if(dataHeader.operationType == MOVE_OPERATION) {
        if(moveEnabled) {
            // drag-n-drop menu
            InsertMenu (hmenu, uMenuIndex, MF_BYPOSITION,
                        uidFirstCmd, _T("Move using SecureDelete"));
        }
    }
    else if(dataHeader.operationType == RECYCLE_BIN_OPERATION) {
        if(recycleEnabled) {
            // not implemented
        }
    }
    else if(normalEnabled) {
        // standard menu
        InsertMenu (hmenu, uMenuIndex, MF_BYPOSITION,
                    uidFirstCmd, _T("Wipe using SecureDelete"));
    }

    return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1);
}
예제 #2
0
//
//   FUNCTION: FileContextMenuExt::QueryContextMenu
//
//   PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the 
//            context menu handler to add its menu items to the menu. It 
//            passes in the HMENU handle in the hmenu parameter. The 
//            indexMenu parameter is set to the index to be used for the 
//            first menu item that is to be added.
//
IFACEMETHODIMP FileContextMenuExt::QueryContextMenu(
    HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
    // If uFlags include CMF_DEFAULTONLY then we should not do anything.
    if (CMF_DEFAULTONLY & uFlags)
    {
        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
    }

    // Use either InsertMenu or InsertMenuItem to add menu items.
    // Learn how to add sub-menu from:
    // http://www.codeproject.com/KB/shell/ctxextsubmenu.aspx

	UINT uID = idCmdFirst;

    MENUITEMINFO mii = { sizeof(mii) };
    mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
    mii.wID = uID++;
    mii.fType = MFT_STRING;
    mii.dwTypeData = m_pszMenuText;
    mii.fState = MFS_ENABLED;
    mii.hbmpItem = static_cast<HBITMAP>(m_hMenuBmp);
    if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii))
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

	HMENU hSubmenu = CreatePopupMenu();
    InsertMenu ( hSubmenu, 0, MF_BYPOSITION, uID++, L"&Shred Quick" );
	InsertMenu ( hSubmenu, 1, MF_BYPOSITION, uID++, L"&Shred Safe" );
	InsertMenu ( hSubmenu, 1, MF_BYPOSITION, uID++, L"&Shred Through" );

	MENUITEMINFO mii2 = { sizeof(mii2) };
    mii2.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_SUBMENU | MIIM_STATE;
    mii2.fType = MFT_STRING;
	mii2.wID = IDM_SHRED;
    mii2.dwTypeData = m_pszMenuText2;
    mii2.hbmpItem = static_cast<HBITMAP>(m_hMenuBmp);
	mii.fState = MFS_ENABLED;
	mii2.hSubMenu = hSubmenu;

    if (!InsertMenuItem(hMenu, indexMenu + 1, TRUE, &mii2))
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

    // Add a separator.
    MENUITEMINFO sep = { sizeof(sep) };
    sep.fMask = MIIM_TYPE;
    sep.fType = MFT_SEPARATOR;
    if (!InsertMenuItem(hMenu, indexMenu + 2, TRUE, &sep))
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

    // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. 
    // Set the code value to the offset of the largest command identifier 
    // that was assigned, plus one (1).
    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(5));
}
STDMETHODIMP CHashCheck::QueryContextMenu( HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags )
{
	if (uFlags & (CMF_DEFAULTONLY | CMF_NOVERBS))
		return(MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0));

	// Ugly hack: work around a bug in Windows 5.x that causes a spurious
	// separator to be added when invoking the context menu from the Start Menu
	if (g_uWinVer < 0x0600 && !(uFlags & (0x20000 | CMF_EXPLORE)) && GetModuleHandleA("explorer.exe"))
		return(MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0));

	// Load the menu display settings
	HASHCHECKOPTIONS opt;
	opt.dwFlags = HCOF_MENUDISPLAY;
	OptionsLoad(&opt);

	// Do not show if the settings prohibit it
	if (opt.dwMenuDisplay == 2 || (opt.dwMenuDisplay == 1 && !(uFlags & CMF_EXTENDEDVERBS)))
		return(MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0));

	// Load the localized menu text
	TCHAR szMenuText[MAX_STRINGMSG];
	LoadString(g_hModThisDll, IDS_HS_MENUTEXT, szMenuText, countof(szMenuText));

	if (InsertMenu(hmenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst, szMenuText))
		return(MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1));

	return(MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0));
}
예제 #4
0
//
//   FUNCTION: ContextMenuExt::QueryContextMenu
//
//   PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the 
//            context menu handler to add its menu items to the menu. It 
//            passes in the HMENU handle in the hmenu parameter. The 
//            indexMenu parameter is set to the index to be used for the 
//            first menu item that is to be added.
//
// doc about MENUITEMINFO: 
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms647578(v=vs.85).aspx
//
// doc about InsertMenuItem:
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms647988(v=vs.85).aspx
//
IFACEMETHODIMP ContextMenuExt::QueryContextMenu(
    HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
    // If uFlags include CMF_DEFAULTONLY then we should not do anything.
    if (CMF_DEFAULTONLY & uFlags)
    {
        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
    }

	// context menu menu handle
	m_hTopMenu = hMenu;
	// position index
	m_topMenuIndex = indexMenu;
	m_subMenuIndex = 0;
	// command id
	m_firstCmdId = idCmdFirst;
	m_currentCmdId = idCmdFirst;

	m_cmdIdToCommand.clear();

	// create and populate the submenu.
	if (!CreateSubMenu()) {
		return HRESULT_FROM_WIN32(GetLastError());
	}

	// create and populate top level menu
	if (!CreateTopMenu()) {
		return HRESULT_FROM_WIN32(GetLastError());
	}
	
    // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. 
    // Set the code value to the offset of the largest command identifier 
    // that was assigned, plus one (1).
	return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(m_currentCmdId - idCmdFirst + 1));
}
STDMETHODIMP CShooterContextMenuExt::QueryContextMenu (
    HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
    UINT uidLastCmd, UINT uFlags )
{
	// If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if ( uFlags & CMF_DEFAULTONLY )
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

	InsertMenu ( hmenu, uMenuIndex, MF_SEPARATOR|MF_BYPOSITION, 0, NULL );

	UINT uidCmd = uidFirstCmd;
	uMenuIndex++;
    InsertMenu ( hmenu, uMenuIndex, MF_BYPOSITION, uidCmd, _T("¤U¸ü¦r¹õ") );
	// Set the bitmap.
    if ( NULL != m_hIcon )
        SetMenuItemBitmaps ( hmenu, uMenuIndex, MF_BYPOSITION, m_hIcon, NULL );

	if(!m_bHasDir)
	{
		uMenuIndex++;
		uidCmd++;
		InsertMenu ( hmenu, uMenuIndex, MF_BYPOSITION, uidCmd, _T("¦r¹õ²ÂàÁc") );
		// Set the bitmap.
		if ( NULL != m_hIcon )
			SetMenuItemBitmaps ( hmenu, uMenuIndex, MF_BYPOSITION, m_hIcon, NULL );
	}

	uMenuIndex++;
	InsertMenu ( hmenu, uMenuIndex, MF_SEPARATOR|MF_BYPOSITION, 0, NULL );


    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, uidCmd - uidFirstCmd + 1 );
}
예제 #6
0
STDMETHODIMP CWorkshareMenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
	RighClickMenuManger rcm(m_vSelectedDocuments);

	if (((!(CMF_DEFAULTONLY & indexMenu)) && (rcm.IsAtLeastOneMenuItemVisible())))
	{
		::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_SEPARATOR,  NULL, NULL );										

		if (rcm.ShowCompareInDeltaView())
			::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + COMPARE_WITH_DELTAVIEW_MENU_OFFSET, (LPCTSTR)COMPARE_WITH_DELTAVIEW_MENU_OFFSET );										
		
		if (rcm.ShowConvertToPdf())
			::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + CONVERT_TO_PDF_OFFSET, (LPCTSTR)CONVERT_TO_PDF_OFFSET );										
		
		if (rcm.ShowOpenPdfInWord())
			::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + OPEN_PDF_IN_WORD_OFFSET, (LPCTSTR)OPEN_PDF_IN_WORD_OFFSET );										

		if (rcm.ShowCombineToPdf())
			::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_OWNERDRAW, idCmdFirst + COMBINE_PDF_OFFSET, (LPCTSTR)COMBINE_PDF_OFFSET);										

	
		
		::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION|MF_SEPARATOR,  NULL, NULL );	
		return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, COMBINE_PDF_OFFSET + 1 );
	}
	return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, USHORT(0));
}
예제 #7
0
HRESULT CShellExt::QueryContextMenu(HMENU hmenu,UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags)
{
	UINT uCmdID = uidFirstCmd;
	// If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
	if ( uFlags & CMF_DEFAULTONLY )
		return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

	// Add our register/unregister items.
	InsertMenu ( hmenu, uMenuIndex, MF_STRING | MF_BYPOSITION, uCmdID++,
		_T("&CMD") );


	uMenuIndex++;

	InsertMenu ( hmenu, uMenuIndex, MF_STRING | MF_BYPOSITION, uCmdID++,
		_T("&Visual Studio 2008 Command Prompt") );


	uMenuIndex++;

	// The return value tells the shell how many top-level items we added.
	return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 2 );



}
예제 #8
0
HRESULT __stdcall BtrfsContextMenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) {
    WCHAR str[256];
    
    if (ignore)
        return E_INVALIDARG;
    
    if (uFlags & CMF_DEFAULTONLY)
        return S_OK;
    
    if (!bg) {
        if (LoadStringW(module, IDS_CREATE_SNAPSHOT, str, sizeof(str) / sizeof(WCHAR)) == 0)
            return E_FAIL;

        if (!InsertMenuW(hmenu, indexMenu, MF_BYPOSITION, idCmdFirst, str))
            return E_FAIL;

        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
    }
    
    if (LoadStringW(module, IDS_NEW_SUBVOL, str, sizeof(str) / sizeof(WCHAR)) == 0)
        return E_FAIL;

    if (!InsertMenuW(hmenu, indexMenu, MF_BYPOSITION, idCmdFirst, str))
        return E_FAIL;

    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
}
예제 #9
0
STDMETHODIMP ContextMenu::QueryContextMenu(HMENU hMenu,
                                             UINT indexMenu,
                                             UINT idCmdFirst,
                                             UINT idCmdLast,
                                             UINT uFlags)
{
    //HRESULT hr;
	
    if (!(CMF_DEFAULTONLY & uFlags))
    {
        InsertMenu(hMenu, 
                   indexMenu, 
                   MF_STRING | MF_BYPOSITION, 
                   idCmdFirst + IDM_SHAREWITHBOX, 
                   MENU_A);

	    if (m_hbmp)
		{
		    SetMenuItemBitmaps( hMenu, 
                   indexMenu, 
                   MF_STRING | MF_BYPOSITION,
				   m_hbmp, m_hbmp);
		}

        // TODO: Add error handling to verify HRESULT return values.
		
        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_SHAREWITHBOX + 1));
    }

    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
}
예제 #10
0
STDMETHODIMP CDDShellExt::QueryContextMenu(HMENU hmenu,UINT uMenuIndex,UINT uidFirstCmd,UINT uidLastCmd,UINT uFlags)
{
	(void)uidLastCmd;
	if(!m_ac.isConnected())
	{
		if(!m_ac.connectToServer())
			return E_FAIL;
	}
	if (uFlags&CMF_DEFAULTONLY)
		return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0);

	int x=uidFirstCmd;

	InsertMenu(hmenu,uMenuIndex++,MF_STRING|MF_BYPOSITION,x++,_T("Copy") _T(" - ") _T(CATCHCOPY_EXPLORER_PLUGIN_SOFTWARE_NAME));
	InsertMenu(hmenu,uMenuIndex++,MF_STRING|MF_BYPOSITION,x++,_T("Move") _T(" - ") _T(CATCHCOPY_EXPLORER_PLUGIN_SOFTWARE_NAME));

	int defItem=GetMenuDefaultItem(hmenu,false,0);
	if (defItem==1) // 1: Copy
	{
		if (fFromExplorer)
			SetMenuDefaultItem(hmenu,uidFirstCmd,false);
	}
	else if (defItem==2) //2: Move
	{
		SetMenuDefaultItem(hmenu,uidFirstCmd+1,false);
	}
	return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,2);
}
void CHyperFeedStructureInfo::Attach()
{
	long nRes = CMasterOptions::Attach();
	if(nRes != DBA_ERR_NO_ERROR)
	{
		Sleep(500);
		nRes = CMasterOptions::Attach();
		if(nRes != DBA_ERR_NO_ERROR)
		{
			HRESULT hr = MAKE_HRESULT (SEVERITY_ERROR, FACILITY_ITF, nRes);
			EgLib::CComErrorWrapper::ThrowError(hr, _T("Failed to attach to master options database."));
		}
	}
	nRes = COptions::Attach();
	if(nRes != DBA_ERR_NO_ERROR)
	{
		HRESULT hr = MAKE_HRESULT (SEVERITY_ERROR, FACILITY_ITF, nRes);
		EgLib::CComErrorWrapper::ThrowError(hr, _T("Failed to attach to price database."));
	}
	nRes = CUnderlyings::Attach();
	if(nRes != DBA_ERR_NO_ERROR)
	{
		HRESULT hr = MAKE_HRESULT (SEVERITY_ERROR, FACILITY_ITF, nRes);
		EgLib::CComErrorWrapper::ThrowError(hr, _T("Failed to attach to security profile database."));
	}	
}
예제 #12
0
HRESULT
CSurrogate::ParseCommandLine(LPSTR szCmdParam,
                             CLSID *pclsidInitial,
                             GUID  *pappid)
{
    enum { SURROGATE_SUFFIX = 38 + 1 + 10 };
    LPSTR szSuffix = szCmdParam + lstrlenA(szCmdParam) - SURROGATE_SUFFIX;
    HRESULT hr = GUIDFromStringA(szSuffix, pclsidInitial);
    if (SUCCEEDED(hr))
    {
        char sz[128];
        lstrcpyA(sz, "CLSID\\");
        memcpy(sz + 6, szSuffix, 38);
        sz[44] = 0;

        HKEY hkey = 0;
        LONG err = RegOpenKeyExA(HKEY_CLASSES_ROOT, sz, 0, 
                                 KEY_READ, &hkey);
        if (err == ERROR_SUCCESS)
        {
            DWORD cb = sizeof(sz);
            err = RegQueryValueEx(hkey, "AppID", 0, 0, (BYTE*)sz, &cb);
            if (err == ERROR_SUCCESS)
                hr = GUIDFromStringA(sz, pappid);
            else
                hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, err);

            RegCloseKey(hkey);
        }
        else
            hr = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, err);
    }
    return hr;
}
예제 #13
0
파일: DrmShlExt.cpp 프로젝트: Ochieng/drm
//
//   FUNCTION: CDrmShlExt::QueryContextMenu(HMENU, UINT, UINT, UINT, 
//             UINT)
//
//   PURPOSE: The Shell calls IContextMenu::QueryContextMenu to allow the 
//            context menu handler to add its menu items to the menu. It 
//            passes in the HMENU handle in the hmenu parameter. The 
//            indexMenu parameter is set to the index to be used for the 
//            first menu item that is to be added.
//
IFACEMETHODIMP CDrmShlExt::QueryContextMenu(
    HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
    // If uFlags include CMF_DEFAULTONLY then we should not do anything
    if (CMF_DEFAULTONLY & uFlags)
    {
        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
    }

	//unsigned long originalFirst = idCmdFirst; //we'll compute how many items we added from this.
	HBITMAP hBitmap = (HBITMAP)LoadImage((HMODULE)_AtlBaseModule.m_hInst,
		MAKEINTRESOURCE(IDB_PAGE_UNLOCK) , IMAGE_BITMAP, 16, 16, 0);

	InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_DECRYPT, _T("&Decrypt"));
	SetMenuItemBitmaps(hMenu, indexMenu, MF_BITMAP | MF_BYPOSITION, hBitmap, NULL);
	indexMenu++; //this corresponds to the top-level menu index

	// Use either InsertMenu or InsertMenuItem tSo add menu items to the list
    //InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + 
    //    IDM_DECRYPT, _T("&Decrypt"));

    // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. 
    // Set the code value to the offset of the largest command identifier 
    // that was assigned, plus one (1)
    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_DECRYPT + 1));
}
예제 #14
0
파일: recyclebin.c 프로젝트: YokoZar/wine
static HRESULT WINAPI RecycleBin_CompareIDs(IShellFolder2 *iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
{
    RecycleBin *This = impl_from_IShellFolder2(iface);

    /* TODO */
    TRACE("(%p, %p, %p, %p)\n", This, (void *)lParam, pidl1, pidl2);
    if (pidl1->mkid.cb != pidl2->mkid.cb)
        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, pidl1->mkid.cb - pidl2->mkid.cb);
    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (unsigned short)memcmp(pidl1->mkid.abID, pidl2->mkid.abID, pidl1->mkid.cb));
}
예제 #15
0
파일: ksproxy.cpp 프로젝트: Moteesh/reactos
KSDDKAPI
HRESULT
WINAPI
KsSynchronousDeviceControl(
    HANDLE     Handle,
    ULONG      IoControl,
    PVOID      InBuffer,
    ULONG      InLength,
    PVOID      OutBuffer,
    ULONG      OutLength,
    PULONG     BytesReturned)
{
    OVERLAPPED Overlapped;
    DWORD Transferred;

    /* zero overlapped */
    RtlZeroMemory(&Overlapped, sizeof(OVERLAPPED));

    /* create notification event */
    Overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);

    if (!Overlapped.hEvent)
    {
        /* failed */
        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
    }

    if (!DeviceIoControl(Handle, IoControl, InBuffer, InLength, OutBuffer, OutLength, BytesReturned, &Overlapped))
    {
        /* operation failed */
        if (GetLastError() != ERROR_IO_PENDING)
        {
            /* failed */
            CloseHandle(Overlapped.hEvent);
            return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
        }
    }

    /* get result of pending operation */
    if (!GetOverlappedResult(Handle, &Overlapped, &Transferred, TRUE))
    {
        /* failed */
        CloseHandle(Overlapped.hEvent);
        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
    }

    /* store number of bytes transferred */
    *BytesReturned = Transferred;

    /* close event object */
    CloseHandle(Overlapped.hEvent);

    /* done */
    return NOERROR;
}
예제 #16
0
//IContextMenu
HRESULT FileKeeperStuff::QueryContextMenu( 
	/* [in] */ 
	HMENU hmenu,
	/* [in] */ 
	UINT indexMenu,
	/* [in] */ 
	UINT idCmdFirst,
	/* [in] */ 
	UINT idCmdLast,
	/* [in] */ 
	UINT uFlags)
{
	if (!(uFlags & CMF_DEFAULTONLY))
	{
		ModuleContex* pCtx = ModuleContex::GetInstPtr();
		HMODULE hInst = pCtx->GetModuleHandle();

		int nCmdID = idCmdFirst;
		TCHAR szBuf[MAX_PATH] = _T("");
		int nLen = 0;
		int nSubItemIndex = 0;

		HMENU hFKMenu = CreatePopupMenu();

		MENUITEMINFO mii = {sizeof(mii)};	

		nLen = LoadString(hInst, IDS_STRING_ABOUT, szBuf, MAX_PATH) + 1;
		mii.fMask = MIIM_STRING | MIIM_ID; //MIIM_BITMAP
		mii.wID = nCmdID++;
		mii.dwTypeData = szBuf;
		mii.cch = nLen;
		InsertMenuItem(hFKMenu, nSubItemIndex, TRUE, &mii);
		LoadString(hInst, IDS_STRING_ABOUT_HS, szBuf, MAX_PATH);
		pCtx->AddCommandString(nSubItemIndex, szBuf);
		pCtx->AddCommandHandler(nSubItemIndex, &FileKeeperStuff::OnAbout);
		nSubItemIndex++;
		

		memset(&mii, 0, sizeof(mii));
		mii.cbSize = sizeof(mii);
		nLen = LoadString(hInst, IDS_STRING_FILEKEEPER, szBuf, MAX_PATH) + 1;
		mii.fMask = MIIM_SUBMENU | MIIM_STRING | MIIM_ID;
		mii.hSubMenu = hFKMenu;
		mii.wID = nCmdID++;
		mii.dwTypeData = szBuf;
		mii.cch = nLen;
		InsertMenuItem(hmenu, indexMenu, TRUE, &mii);

		return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(nCmdID - idCmdFirst));
	}

	return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));


}
예제 #17
0
HRESULT CContextMenuExt::QueryContextMenu ( HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags )
{
	// If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
	if ( uFlags & CMF_DEFAULTONLY )
		return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

	InsertMenu ( hmenu, uMenuIndex, MF_BYPOSITION,
		uidFirstCmd, _T("Syncany Context Menu") );

	return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 1 );
}
예제 #18
0
 ::HRESULT __stdcall ContextMenu::QueryContextMenu (
     ::HMENU menu, ::UINT index, ::UINT first, ::UINT last, ::UINT flags
     )
 {
     w32::gdi::Menu context(w32::gdi::Menu::proxy(menu));
     if ( (flags & (CMF_NORMAL|CMF_EXPLORE)) != 0 ) {
         ::UINT items = Populate(context,index,first,last);
         return (MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,items));
     }
     return (MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0));
 }
예제 #19
0
//add by ray 2014-05-15 17:48
HRESULT CSimpleShlExt::QueryContextMenu ( HMENU hmenu,UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags )
{          
	// 如果标志包含 CMF_DEFAULTONLY 我们不作任何事情. 
	if ( uFlags & CMF_DEFAULTONLY ) 
	{ 
		return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 ); 
	} 

	InsertMenu ( hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, _T("SimpleShlExt Test Item") ); 
	return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 1 );
}
예제 #20
0
void SslCheck(bool b) {
	if (!b) {
#ifdef OPENSSL_NO_ERR
		throw OpenSslException(MAKE_HRESULT(SEVERITY_ERROR, FACILITY_OPENSSL, 1), "OpenSSL Error"); //!!! code?
#else
		ERR_load_crypto_strings();
		int rc = ::ERR_get_error();
		String sErr = ERR_error_string(rc, 0);
		throw OpenSslException(MAKE_HRESULT(SEVERITY_ERROR, FACILITY_OPENSSL, ERR_GET_REASON(rc)), sErr);
#endif

	}
}
STDMETHODIMP
CShellExtension::QueryContextMenu(
	HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
	UINT uidLastCmd, UINT uFlags)
{
	OutputDebugString(TEXT("Menu Queried"));
	// If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
	if (uFlags & CMF_DEFAULTONLY)
		return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);

	InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, _T("Menu Test Item"));

	return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1);
}
예제 #22
0
STDMETHODIMP CEsteidShlExt::QueryContextMenu (
	HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
	UINT uidLastCmd, UINT uFlags )
{
	// If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
	if (uFlags & CMF_DEFAULTONLY)
		return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);

	InsertMenu(hmenu, uMenuIndex, MF_STRING | MF_BYPOSITION, uidFirstCmd, _T("Allkirjasta ID-kaardiga"));
	if (m_DigidocBmp != NULL)
		SetMenuItemBitmaps(hmenu, uMenuIndex, MF_BYPOSITION, m_DigidocBmp, NULL);

	return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1);
}
예제 #23
0
/**************************************************************************
* ISvItemCm_fnQueryContextMenu()
*/
static HRESULT WINAPI ISvItemCm_fnQueryContextMenu(
	IContextMenu2 *iface,
	HMENU hmenu,
	UINT indexMenu,
	UINT idCmdFirst,
	UINT idCmdLast,
	UINT uFlags)
{
    ItemCmImpl *This = impl_from_IContextMenu2(iface);
    INT uIDMax;

    TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",This, hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags);

    This->verb_offset=idCmdFirst;

    if(!(CMF_DEFAULTONLY & uFlags) && This->cidl>0)
    {
        HMENU hmenures = LoadMenuW(shell32_hInstance, MAKEINTRESOURCEW(MENU_SHV_FILE));

        if(uFlags & CMF_EXPLORE)
            RemoveMenu(hmenures, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);

        uIDMax = Shell_MergeMenus(hmenu, GetSubMenu(hmenures, 0), indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);

        DestroyMenu(hmenures);

        if(This->bAllValues)
        {
            MENUITEMINFOW mi;
            WCHAR str[255];
            mi.cbSize = sizeof(mi);
            mi.fMask = MIIM_ID | MIIM_STRING | MIIM_FTYPE;
            mi.dwTypeData = str;
            mi.cch = 255;
            GetMenuItemInfoW(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND, &mi);
            RemoveMenu(hmenu, FCIDM_SHVIEW_EXPLORE, MF_BYCOMMAND);
            _InsertMenuItemW(hmenu, (uFlags & CMF_EXPLORE) ? 1 : 2, MF_BYPOSITION, FCIDM_SHVIEW_EXPLORE, MFT_STRING, str, MFS_ENABLED);
        }

        SetMenuDefaultItem(hmenu, 0, MF_BYPOSITION);

        if(uFlags & ~CMF_CANRENAME)
            RemoveMenu(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND);
        else
            EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND | ISvItemCm_CanRenameItems(This) ? MFS_ENABLED : MFS_DISABLED);

        return MAKE_HRESULT(SEVERITY_SUCCESS, 0, uIDMax-idCmdFirst);
    }
    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 0);
}
예제 #24
0
/**************************************************************************
* ICPanel_IContextMenu_QueryContextMenu()
*/
HRESULT WINAPI CControlPanelFolder::QueryContextMenu(
    HMENU hMenu,
    UINT indexMenu,
    UINT idCmdFirst,
    UINT idCmdLast,
    UINT uFlags)
{
    WCHAR szBuffer[30] = {0};
    ULONG Count = 1;

    TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",
          this, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);

    if (LoadStringW(shell32_hInstance, IDS_OPEN, szBuffer, sizeof(szBuffer) / sizeof(WCHAR)))
    {
        szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
        _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_OPEN, MFT_STRING, szBuffer, MFS_DEFAULT); //FIXME identifier
        Count++;
    }

    if (LoadStringW(shell32_hInstance, IDS_CREATELINK, szBuffer, sizeof(szBuffer) / sizeof(WCHAR)))
    {
        if (Count)
        {
            _InsertMenuItemW(hMenu, indexMenu++, TRUE, idCmdFirst + Count, MFT_SEPARATOR, NULL, MFS_ENABLED);
        }
        szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';

        _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_CREATELINK, MFT_STRING, szBuffer, MFS_ENABLED); //FIXME identifier
        Count++;
    }
    return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Count);
}
예제 #25
0
bool netbios_name::Register()
{
	m_managed = true;

	UCHAR ret = AddName ();
	LOG("Register NetBIOS name \"%s\" on lana %d num=%d : 0x%02x \"%s\"", GetANSIFullName(), m_lana, netbiosed.name_num, ret, GetNetbiosError( ret ) );
	m_registered = (ret == NRC_GOODRET);
	m_duplicated = (ret == NRC_DUPNAME);
	if ( ret != NRC_GOODRET && ret != NRC_DUPNAME )
	{
		WarningBox (NULL, (DWORD)MAKE_HRESULT (0, FACILITY_NETBIOS, ret),
			_T("%s: %s"), TranslateT ("Cannot register NetBIOS name"), (LPCTSTR)CA2T( GetANSIFullName() ) );
	}

	if (!m_term)
		m_term = CreateEvent (NULL, TRUE, FALSE, NULL);
	else
		ResetEvent (m_term);

	if ( m_term && !m_listener )
		m_listener = (HANDLE)mir_forkthread( ListenerThread, this );

	if ( m_term && !m_dgreceiver &&
		// NOTE: Под Win9x нельзя запускать ожидание датаграмм для имён-дубликатов
		// т.к. потом невозможно выбить управление из функции Netbios() даже если
		// разрегистрировать имя
		!m_duplicated )
	{
		m_dgreceiver = (HANDLE)mir_forkthread( DatagramReceiverThread, this );
	}

	return m_registered;
}
예제 #26
0
HRESULT DynamicDisplayItem::UpdateIconData(int theCode, const ItemIconData * theData)
{
	HRESULT aRes = MAKE_HRESULT(0, 0, 0);

	if (theCode & CHANGE_ICON)
	{
		if (myIconData.IconIndex != theData->IconIndex)
		{
			myIconData.IconIndex = theData->IconIndex;
			aRes |= CHANGE_ICON;
		}
		if (myIconData.ImageList != theData->ImageList)
		{
			myIconData.ImageList = theData->ImageList;
			aRes |= CHANGE_ICON;
		}
		if (myIconData.IsIconDimmed != theData->IsIconDimmed)
		{
			myIconData.IsIconDimmed = theData->IsIconDimmed;
			aRes |= CHANGE_ICON;
		}
	}

	if (theCode & CHANGE_OVERLAY)
	{
		if (myIconData.OverlayIndex != theData->OverlayIndex)
		{
			myIconData.OverlayIndex = theData->OverlayIndex;
			aRes |= CHANGE_OVERLAY;
		}
	}

	return aRes;
}
예제 #27
0
HRESULT CLCDOutput::HandleErrorFromAPI(DWORD dwRes)
{
    switch(dwRes)
    {
        // all is well
    case ERROR_SUCCESS:
    case RPC_S_PROTOCOL_ERROR:
        break;
        // we lost our device
    case ERROR_DEVICE_NOT_CONNECTED:
        LCDUITRACE(_T("lgLcdAPI returned with ERROR_DEVICE_NOT_CONNECTED, closing device\n"));
        Close();
        break;
    default:
        LCDUITRACE(_T("lgLcdAPI returned with other error (0x%08x) closing device\n"));
        Close();
        // something else happened, such as LCDMon that was terminated
        break;
    }

    if(ERROR_SUCCESS != dwRes)
    {
        return MAKE_HRESULT(SEVERITY_ERROR, 0, dwRes);
    }

    return S_OK;
}
예제 #28
0
	void InsertTx(const Tx& tx, const TxHashesOutNums& hashesOutNums, const HashValue& txHash, int height, const ConstBuf& txIns, const ConstBuf& spend, const ConstBuf& data) override {
		CoinEng& eng = Eng();

		m_cmdInsertTx
			.Bind(1, ReducedHashValue(txHash))
			.Bind(2, (Int64)height)
			.Bind(3, txIns)
			.Bind(4, spend);

		m_cmdInsertTx.Bind(5, data);
		try {
			DBG_LOCAL_IGNORE_NAME(MAKE_HRESULT(SEVERITY_ERROR, FACILITY_SQLITE, SQLITE_CONSTRAINT_PRIMARYKEY), ignSQLITE_CONSTRAINT_PRIMARYKEY);
					
			m_cmdInsertTx.ExecuteNonQuery();
		} catch (const SqliteException&) {
			TRC(1, "Duplicated Transaction: " << txHash);

			if (height >= eng.ChainParams.CheckDupTxHeight && ContainsInLinear(GetCoinsByTxHash(txHash), true))
				Throw(E_COIN_DupNonSpentTx);						

			SqliteCommand("UPDATE txes SET coins=? WHERE id=?", m_db)
				.Bind(1, spend)
				.Bind(2, ReducedHashValue(txHash))
				.ExecuteNonQuery();
		}
		if (eng.Mode == EngMode::BlockExplorer)
			InsertPubkeyToTxes(tx);
	}
예제 #29
0
파일: jdllcomx.cpp 프로젝트: EdKeith/core
STDMETHODIMP CJServerFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, PPVOID ppvObj)
{
    CJServer* pObj;
    HRESULT hr;

    *ppvObj=NULL;
    if (NULL!=pUnkOuter && IID_IUnknown!=riid)
        return ResultFromScode(CLASS_E_NOAGGREGATION);

#ifdef _JDLL
//! java doesn't seem to unload properly
//  repeated refresh of calc applet gets cocreate failure on odd times
//  but this change isn't right either
//  because it reconnects to the same dll
//  kludge java fix is to remove following g_cObj line
//	if(g_cObj) return MAKE_HRESULT(S_FALSE, FACILITY_ITF, EHRSINGLE);
#else
	if(g_cObj) return MAKE_HRESULT(S_FALSE, FACILITY_ITF, EHRSINGLE);
#endif
	pObj=new CJServer(pUnkOuter, ObjectDestroyed);
    if (NULL==pObj) return E_OUTOFMEMORY;
    if (!pObj->Init()) return E_OUTOFMEMORY;
    hr=pObj->QueryInterface(riid, ppvObj);
    if (FAILED(hr))
    	delete pObj;
    else
        g_cObj++;
    return hr;
}
예제 #30
0
HRESULT
COMError::GenerateError(HM::String sDescription)
{
   if (sDescription == _T(""))
   {
      sDescription = "The operation failed. Please check the hMailServer log for details.";
   }

   // Get the ICreateErrorInfo Interface
   ICreateErrorInfo *pCreateErrorInfo = NULL;
   HRESULT hSuccess = CreateErrorInfo(&pCreateErrorInfo);
   ATLASSERT(SUCCEEDED(hSuccess));
   // pCreateErrorInfo->SetGUID(CLSID_BaseApp);
   pCreateErrorInfo->SetDescription(sDescription.AllocSysString());
   HM::String sSource = "hMailServer COM library";
   pCreateErrorInfo->SetSource(sSource.AllocSysString());

   IErrorInfo *pErrInfo;

   if (SUCCEEDED(pCreateErrorInfo->QueryInterface(IID_IErrorInfo, 
      reinterpret_cast<void**>(&pErrInfo))))
   {
      SetErrorInfo(0, pErrInfo);
      pErrInfo->Release();
   }

   pCreateErrorInfo->Release();

   return MAKE_HRESULT(1, FACILITY_ITF, 1001);
}