/// The Microsoft ATL _com_error is not derived from std::exception hence this bit of code to throw our own COMexception() instead static void __stdcall my_com_raise_error(HRESULT hr, IErrorInfo* perrinfo) { _com_error com_error(hr, perrinfo); // std::string message = "(" + com_error.Source() + ") " + com_error.Description(); _bstr_t desc = com_error.Description(); std::string message = (desc.GetBSTR() != NULL ? desc : ""); // for LabVIEW generated messages, Description() already includes Source() throw COMexception(message, hr); }
shared_ptr<ITEMIDLIST_ABSOLUTE> pidl_from_path( const wpath& filesystem_path) { PIDLIST_ABSOLUTE pidl; HRESULT hr = ::SHILCreateFromPath( filesystem_path.file_string().c_str(), &pidl, NULL); if (FAILED(hr)) BOOST_THROW_EXCEPTION(com_error(hr)); return shared_ptr<ITEMIDLIST_ABSOLUTE>(pidl, ::ILFree); }
/** Display dialog to get connection info from user. */ void Add::operator()(const com_ptr<IDataObject>&, const com_ptr<IBindCtx>&) const { host_info info = add_host(m_hwnd); if (ConnectionExists(info.name)) BOOST_THROW_EXCEPTION(com_error(E_FAIL)); AddConnectionToRegistry( info.name, info.host, info.port, info.user, info.path); notify_shell(m_folder_pidl); }
/** * @return target machine's platform. */ CExpressModeDlg::TARGET_PLATFORM CExpressModeDlg::GetPlatform(void) const { if (m_strPlatform.CompareNoCase(_T("Win32")) == 0 || m_strPlatform.CompareNoCase(_T("Win32-x86")) == 0) { return TPLAT_X86; } else if (m_strPlatform.CompareNoCase(_T("Win64-x64")) == 0) { return TPLAT_X64; } else { CStringA strErrorMessage; strErrorMessage.LoadString(IDS_ERROR_UNSUPPORTEDPLATFORM); throw com_error(strErrorMessage); } }
/** * @param strFilePath - document file path. */ void CExpressModeDlg::LoadXMLDocument(const CString& strFilePath) { ClearData(); HRESULT hRes = m_pXMLDocument.CoCreateInstance(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER); CHECK_HRESULT(hRes); m_pXMLDocument->setProperty(CComBSTR(OLESTR("SelectionLanguage")), CComVariant(OLESTR("XPath"))); m_pXMLDocument->put_async(VARIANT_FALSE); VARIANT_BOOL bSuccess = VARIANT_FALSE; hRes = m_pXMLDocument->load(CComVariant(strFilePath), &bSuccess); CHECK_HRESULT(hRes); if (! bSuccess) { CComPtr<IXMLDOMParseError> pXMLError; hRes = m_pXMLDocument->get_parseError(&pXMLError); if (hRes == S_OK) { long lErrorCode = 0; pXMLError->get_errorCode(&lErrorCode); if (lErrorCode != 0) { CComBSTR bstrError; pXMLError->get_reason(&bstrError); throw com_error(lErrorCode, CW2A(bstrError)); } } CStringA strError; strError.LoadString(IDS_ERROR_XMLLOADERROR); throw com_error(strError); } hRes = m_pXMLDocument->get_documentElement(&m_pXMLElementDocument); CHECK_HRESULT(hRes); CComVariant varReportVersion; hRes = m_pXMLElementDocument->getAttribute(CComBSTR(OLESTR("version")), &varReportVersion); CHECK_HRESULT(hRes); if (hRes == S_OK) { hRes = varReportVersion.ChangeType(VT_I4); CHECK_HRESULT(hRes); if (V_I4(&varReportVersion) != 1) { CStringA strErrorMessage; strErrorMessage.LoadString(IDS_ERROR_UNSUPPORTEDREPORTVERSION); throw com_error(strErrorMessage); } } if (GetXMLNodeText(m_pXMLElementDocument, OLESTR("./platform"), m_strPlatform)) { // validate platform GetPlatform(); } if (SelectXMLNode(m_pXMLElementDocument, OLESTR("./error"), m_pXMLNodeError)) { CString strProcessID; GetXMLNodeText(m_pXMLNodeError, OLESTR("./process/id"), strProcessID); if (! strProcessID.IsEmpty()) { CString strExpression; strExpression.Format(_T("./processes/process[id=%s]"), strProcessID); SelectXMLNode(m_pXMLElementDocument, CT2W(strExpression), m_pXMLNodeProcess); } } }
int commands_plugin_inte6(void) { #define MAX_ARGS 63 char *args[MAX_ARGS + 1]; struct PSP *psp; struct MCB *mcb; struct com_program_entry *com; int argc; if (pool_used >= MAX_NESTING) { com_error("Cannot invoke more than %i builtins\n", MAX_NESTING); return 0; } if (!pool_used) { if (!(lowmem_pool = lowmem_heap_alloc(LOWMEM_POOL_SIZE))) { error("Unable to allocate memory pool\n"); return 0; } sminit(&mp, lowmem_pool, LOWMEM_POOL_SIZE); } pool_used++; BMEM(allocated) = 0; BMEM(retcode) = 0; if (HI(ax) != BUILTINS_PLUGIN_VERSION) { com_error("builtins plugin version mismatch: found %i, required %i\n", HI(ax), BUILTINS_PLUGIN_VERSION); com_error("You should update your generic.com, ems.sys, isemu.com and other utilities\n" "from the latest dosemu package!\n"); commands_plugin_inte6_done(); return 0; } psp = COM_PSP_ADDR; mcb = LOWMEM(SEGOFF2LINEAR(COM_PSP_SEG - 1,0)); /* first parse commandline */ args[0] = strdup(com_getarg0()); strupperDOS(args[0]); argc = com_argparse((char *)&psp->cmdline_len, &args[1], MAX_ARGS - 1) + 1; /* DOS 4 and up */ strncpy(builtin_name, mcb->name, sizeof(builtin_name) - 1); builtin_name[sizeof(builtin_name) - 1] = 0; strupperDOS(builtin_name); com = find_com_program(builtin_name); /* DOS 3.0->3.31 construct the program name from the environment */ if(!com) { char *p = strrchr(args[0],'\\'); strncpy(builtin_name, p+1, sizeof(builtin_name) - 1); builtin_name[sizeof(builtin_name) - 1] = 0; p = strchr(builtin_name, '.'); if(p) *p = '\0'; com = find_com_program(builtin_name); } if (com) { int err = com->program(argc, args); if (!err) { NOCARRY; } else { CARRY; _AL = err; } } else { com_error("inte6: unknown builtin: %s\n",builtin_name); CARRY; _AL = 1; } free(args[0]); return 1; }