当前位置: 首页>>代码示例>>C++>>正文


C++ MAKE_HRESULT函数代码示例

本文整理汇总了C++中MAKE_HRESULT函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKE_HRESULT函数的具体用法?C++ MAKE_HRESULT怎么用?C++ MAKE_HRESULT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MAKE_HRESULT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MAKE_HRESULT

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);
}
开发者ID:datascicat,项目名称:SecureDelete,代码行数:28,代码来源:SDShellExt.cpp

示例2: MAKE_HRESULT

//
//   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));
}
开发者ID:Axovera,项目名称:CPC,代码行数:69,代码来源:FileContextMenuExt.cpp

示例3: return

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));
}
开发者ID:hashhar,项目名称:hash-check-klui-shellex,代码行数:28,代码来源:CHashCheck.cpp

示例4: MAKE_HRESULT

//
//   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));
}
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:50,代码来源:ContextMenuExt.cpp

示例5: MAKE_HRESULT

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 );
}
开发者ID:4770K,项目名称:shooter-downloader,代码行数:33,代码来源:ShooterContextMenuExt.cpp

示例6: rcm

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));
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:27,代码来源:WorkshareMenu.cpp

示例7: MAKE_HRESULT

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 );



}
开发者ID:grimtraveller,项目名称:utocode,代码行数:26,代码来源:ShellExt.cpp

示例8: MAKE_HRESULT

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);
}
开发者ID:reactos,项目名称:reactos,代码行数:27,代码来源:contextmenu.cpp

示例9: InsertMenu

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));
}
开发者ID:UrsusHorribilis,项目名称:simpleshare,代码行数:31,代码来源:contextmenu.cpp

示例10: MAKE_HRESULT

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);
}
开发者ID:blizzard4591,项目名称:Catchcopy,代码行数:28,代码来源:DDShellExt.cpp

示例11: Sleep

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."));
	}	
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:26,代码来源:hyperfeedstructureinfo.cpp

示例12: lstrlenA

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;
}
开发者ID:alannet,项目名称:example,代码行数:34,代码来源:CSurrogate.cpp

示例13: MAKE_HRESULT

//
//   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));
}
开发者ID:Ochieng,项目名称:drm,代码行数:36,代码来源:DrmShlExt.cpp

示例14: RecycleBin_CompareIDs

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));
}
开发者ID:YokoZar,项目名称:wine,代码行数:10,代码来源:recyclebin.c

示例15: KsSynchronousDeviceControl

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;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:55,代码来源:ksproxy.cpp


注:本文中的MAKE_HRESULT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。