win7系统,用c#调用Interop.SHDocVw.dll时,报了个对“ COM 组件的调用返回了错误 HRESULT E_FAIL”的错误。
在此记录一下: 断言报错的代码如下: HRESULT CIoCPWorker::UnregIoTask(HRESULT hIokey) { ENTER_CALL("CIoCPWorker_UnregIoTask..._GetCount()); return E_FAIL; } } 调用的代码如下: // 被动关闭/关闭超时 void CTcpPort::EndClose(HRESULT reason) {...看了一下S_OK和SUCCEEDED的声明: #define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) #define S_OK ((HRESULT)0x00000000L...只是结果不是想要的 E_FAIL是必须处理的错误。 返回E_FAIL,是告诉调用程序--某些地方出错,必须进行处理。否则,程序不能进行下去了。 返回S_FALSE,不是表示出现错误。...当自己写的函数接口返回值为HRESULT的时候,如果想要指明其出错,并且必须被处理时,应返回E_FAIL。
& spElem ) { HRESULT hr = E_FAIL; do { CComPtr spMainDoc...& vecStSingleinfo ) { HRESULT hr = E_FAIL; do { // 下标没有从0开始!...hRes = E_FAIL; HRESULT hr = E_FAIL; do { CComPtr spElemCollection...HRESULT CDeal12306WebPage::SetCaptchaEx( CComPtr& spTableQrTbody ) { HRESULT hr = E_FAIL...CDeal12306WebPage::ConfirmOrd( CComPtr & spDoc ) { HRESULT hr = E_FAIL; do {
> & spDoc, CComPtr & spInnerDoc ) { HRESULT hr = E_FAIL; do { hr...> & spDoc, CComPtr & spMainDoc ) { HRESULT hr = E_FAIL; do { CComPtr...> & spQueryButtonElem ) { HRESULT hr = E_FAIL; do { CComPtr spMainDoc...CDeal12306WebPage::InsertButtons(CComPtr & spEnter_wElem ) { HRESULT hr = E_FAIL;...HRESULT CDeal12306WebPage::GetQueryInfoInTr( CComPtr & spElem) { HRESULT hr = E_FAIL
HRESULT CWMI::InitialCom() { HRESULT hr = E_FAIL; do { hr = CoInitializeEx(0, COINIT_MULTITHREADED...HRESULT CWMI::ObtainLocator2WMI(CComPtr& pLoc) { HRESULT hr = E_FAIL; do {...= E_FAIL; do { hr = pLoc->ConnectServer( CComBSTR(m_wstrNamespace.c_str()),...HRESULT CWMI::SetProxySecLevels( CComPtr pSvc ) { HRESULT hr = E_FAIL; do {...HRESULT hr = E_FAIL; CComPtr pLoc = NULL; CComPtr pSvc = NULL;
\Common/MyWindows.h:83:19: note: expanded from macro 'E_NOTIMPL' #define E_NOTIMPL ((HRESULT)0x80004001L...\Common/MyWindows.h:84:23: note: expanded from macro 'E_NOINTERFACE' #define E_NOINTERFACE ((HRESULT)...2147467259, which cannot be narrowed to type 'DWORD' (aka 'unsigned int') [-Wc++11-narrowing] case E_FAIL...: txt = "E_FAIL"; break ; ^ ../../.....\Common/MyWindows.h:86:16: note: expanded from macro 'E_FAIL' #define E_FAIL ((HRESULT)0x80004005L)
WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); HRESULT...Render(); ValidateRect(hwnd,NULL); return 0; } return DefWindowProc(hwnd,uMsg,wParam,lParam); } HRESULT...WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); HRESULT...InitD3D(HWND hwnd); VOID Cleanup(); VOID Render(); ////////////////////////////////// HRESULT InitVB...////////////////////// g_pD3DDevice->EndScene(); g_pD3DDevice->Present(NULL,NULL,NULL,NULL); } HRESULT
& stTrainPassenger ) { HRESULT hr = E_FAIL; do { CComPtr spBody;...hr = E_FAIL; do { CComPtr spElemCollecion; hr = GetElementCollection( spElem...hr = E_FAIL; do { CComPtr spElemCollection; hr = GetElementCollection(...hr = E_FAIL; do { CComPtr spTd; hr = GetElementByID(spElem, cstrID...hr = E_FAIL; do { CComPtr spTd; hr = GetElementByID(spElem, cstrID
{ return E_FAIL; } 33....{ return E_FAIL; } 39....if (HRESULT_FACILITY(hr) == FACILITY_WINDOWS) 70. hr = HRESULT_CODE(hr); 71. 72....HRESULT hr; 175....if (HRESULT_FACILITY(hr) == FACILITY_WINDOWS) 24. hr = HRESULT_CODE(hr); 25. 26.
[cpp] view plain copy template class CComCreator2 { public: static HRESULT...; #define DECLARE_ONLY_AGGREGATABLE(x) public:/ typedef ATL::CComCreator2,创建时直接返回E_FAIL。 CComAggObject提供了两个IUnknown的实现。...END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT()//声明和定义了GetControllingUnknown函数 HRESULT FinalConstruct...(){ HRESULT hr = S_OK; if(!
EnterCriticalSection(&m_cs); CComPtr spIUnknown; IStream* spIStream = NULL; HRESULT...CoMarshalInterThreadInterfaceInStream( __uuidof(IWebBrowser2), spIUnknown, &spIStream ); } catch (...) { hr = E_FAIL...HRESULT CAutoMan::ConvertInterface() { HRESULT hr = E_FAIL; CComPtr spTempWebB...iterLast), __uuidof(IWebBrowser2), (LPVOID*)&spTempWebB ); } catch(...) { hr = E_FAIL...if ( NULL == m_spWindow ) { continue; } CComBSTR bstrUrl; HRESULT
shitoub01.jpg”, &g_pTexture ) ) ) { MessageBox(NULL, L”创建纹理失败”, L”Texture.exe”, MB_OK); return E_FAIL...; } HRESULT hr; hr = D3DXCreateTexture(g_pd3dDevice, 256,256,1,D3DUSAGE_RENDERTARGET|D3DUSAGE_AUTOGENMIPMAP...); } // —————————————————————————– // Desc: 初始化Direct3D // —————————————————————————– HRESULT...SetupWorld(); SetupMatrices(); return S_OK; } // —————————————————————————– HRESULT...; } HRESULT hr; hr = D3DXCreateTexture(g_pd3dDevice, 256 , 256 , 1 ,D3DUSAGE_RENDERTARGET
Windows 协议文档中所描述的协议规范中,错误码使用 HRESULT、Win32 错误码和 NTSTATUS 来描述。本文科普一下 HRESULT。...一个简单的例子 我们先举一个大家可能常用的 HRESULT 例子,这样后面的介绍能更简单一点。...规范中的 HRESULT 按照规范,HRESULT 的格式如下,其中首行的数字代表第几位(bit): 0 1 2 3 4 5~15 16~31 S R C N X Facility Code S: 1...break; } } 由于磁盘空间已满没有对应的 .NET Exception,所以我们只能通过提取 IOException 中的 HResult 属性来判断操作的 HRESULT 值。...& 0xFFFF; return errorCode == ERROR_DISK_FULL; } 参考资料 MS-ERREF: HRESULT - Microsoft Docs HRESULT
Lock() throw() { EnterCriticalSection(&m_sec); return S_OK; } HRESULT... Init() throw() { HRESULT hRes = E_FAIL; __try { InitializeCriticalSection...CComAutoCriticalSection::Init should never be called HRESULT Term(); // Not implemented. ... S_OK; } HRESULT Unlock() throw() { return S_OK; } HRESULT Init() throw() { return S_OK; ... CComCritSecLock::Lock() throw() { HRESULT hr; ATLASSERT( !
常量定义 typedef long HRESULT; enum HResult { S_OK = ((HRESULT)0x00000000),.../**< 成功,值为0 */ S_FALSE = ((HRESULT)0x00000001), /**< 成功,但值为1 */ E_FAIL = _HRESULT_TYPEDEF...常量定义 typedef long HRESULT; enum HResult { S_OK = ((HRESULT)0x00000000), /**< 成功,值为0 */ S_FALSE...= ((HRESULT)0x00000001), /**< 成功,但值为1 */ E_FAIL = _HRESULT_TYPEDEF_(0x80004005), /**< 未定义错误 */ E_NOTIMPL...SUCCEEDED(Status) ((HRESULT)(Status) >= 0) /// 判定 HRESULT 值是否为失败值 #define FAILED(Status) ((HRESULT)(
不同的使用方式只要完成其核心功能即可,回顾下CWMI类的执行主体 HRESULT CWMI::ExcuteFun() { HRESULT hr = E_FAIL; CComPtr<IWbemLocator...wstrMethod, const std::wstring& wstrRet, const ParamsMap& params); ~CExcuteMethod(void); private: HRESULT...在执行的主体函数Excute中,我们首先使用WMI类名获取类 HRESULT CExcuteMethod::Excute( CComPtr pSvc ) { HRESULT
DWORD_PTR dw) throw()/ {/ _ComMapClass* p = (_ComMapClass*)pv;/ p->Lock();/ HRESULT...hRes = E_FAIL; / __try / { / hRes = ATL::CComObjectRootBase::_Cache(pv,...[cpp] view plain copy static HRESULT WINAPI InternalQueryInterface(void* pThis, const _ATL_INTMAP_ENTRY...* pEntries, REFIID iid, void** ppvObject) { HRESULT hRes = AtlInternalQueryInterface(pThis, pEntries...[cpp] view plain copy HRESULT _InternalQueryInterface(REFIID iid, void** ppvObject) throw() / { return
在c#代码中处理一些系统出现的异常的时候,常常需要对异常的HResult属性进行处理。...---- 于是我们就会写出以下代码 if(e.HResult==0x80030005) { ... } 然而有时候会惊奇的发现结果并没有如预期的进入if分支 so why 事实上如果你安装了Resharper...因为我们的HResult的值是uint,而Exception.HResult是int所以比较结果必然是false 那么怎么办呢?...都转成uint if((uint)e.HResult==0x80030005) { ... } 都转成int if(e.HResult==uncheck((int)0x80030005) { ......for an HRESULT of S_OK - Stack Overflow ---- 本文会经常更新,请阅读原文: https://xinyuehtx.github.io/post/HResult
就意味着这是一个通用的错误,没有具体的原因 调用 COM 组件,提示 System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT...E_FAIL has been returned from a call to a COM component.
常量定义 typedef long HRESULT; enum HResult { S_OK = ((HRESULT)0x00000000), /**< 成功,值为0 */ S_FALSE...= ((HRESULT)0x00000001), /**< 成功,但值为1 */ E_FAIL = _HRESULT_TYPEDEF_(0x80004005), /**< 未定义错误 */ E_NOTIMPL...= _HRESULT_TYPEDEF_(0x80004001), /**< 接口未实现 */ E_OUTOFMEMORY = _HRESULT_TYPEDEF_(0x8007000E), /**<...*/ E_UNEXPECTED = _HRESULT_TYPEDEF_(0x8000FFFF) /**< 未预料的错误 */ }; /// 判定 HRESULT 值是否为成功值 #define...SUCCEEDED(Status) ((HRESULT)(Status) >= 0) /// 判定 HRESULT 值是否为失败值 #define FAILED(Status) ((HRESULT)
领取专属 10元无门槛券
手把手带您无忧上云