當前位置: 首頁>>代碼示例>>C++>>正文


C++ DisplayLastError函數代碼示例

本文整理匯總了C++中DisplayLastError函數的典型用法代碼示例。如果您正苦於以下問題:C++ DisplayLastError函數的具體用法?C++ DisplayLastError怎麽用?C++ DisplayLastError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了DisplayLastError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: _wsprintf

void CDefaultTerminal::CheckRegisterOsStartup()
{
	LPCWSTR ValueName = StartupValueName;
	bool bCurState = false;
	bool bNeedState = gpSet->isSetDefaultTerminal && gpSet->isRegisterOnOsStartup;
	HKEY hk;
	DWORD nSize; //, nType = 0;
	wchar_t szCurValue[MAX_PATH*3] = {};
	wchar_t szNeedValue[MAX_PATH*2+80] = {};
	LONG lRc;
	bool bPrevTSA = false;

	LPCWSTR pszConfigName = gpSetCls->GetConfigName();
	if (pszConfigName && !*pszConfigName)
		pszConfigName = NULL;

	_wsprintf(szNeedValue, SKIPLEN(countof(szNeedValue)) L"\"%s\" %s%s%s/SetDefTerm /Detached /MinTSA%s",
		gpConEmu->ms_ConEmuExe,
		pszConfigName ? L"/Config \"" : L"", pszConfigName ? pszConfigName : L"", pszConfigName ? L"\" " : L"",
		gpSet->isRegisterOnOsStartupTSA ? L"" : L" /Exit");

	if (IsRegisteredOsStartup(szCurValue, countof(szCurValue)-1, &bPrevTSA) && *szCurValue)
	{
		bCurState = true;
	}

	if ((bCurState != bNeedState)
		|| (bNeedState && (lstrcmpi(szNeedValue, szCurValue) != 0)))
	{
		if (0 == (lRc = RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hk, NULL)))
		{
			if (bNeedState)
			{
				nSize = ((DWORD)_tcslen(szNeedValue)+1) * sizeof(szNeedValue[0]);
				if (0 != (lRc = RegSetValueEx(hk, ValueName, 0, REG_SZ, (LPBYTE)szNeedValue, nSize)))
				{
					DisplayLastError(L"Failed to set ConEmuDefaultTerminal value in HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", lRc);
				}
			}
			else
			{
				if (0 != (lRc = RegDeleteValue(hk, ValueName)))
				{
					DisplayLastError(L"Failed to remove ConEmuDefaultTerminal value from HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", lRc);
				}
			}
			RegCloseKey(hk);
		}
		else
		{
			DisplayLastError(L"Failed to open HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run for write", lRc);
		}
	}
}
開發者ID:AshWilliams,項目名稱:ConEmu,代碼行數:54,代碼來源:DefaultTerm.cpp

示例2: invalid

// static
void Library::HandleShellExecuteError(HINSTANCE h)
{
	/* 
	Returns a value greater than 32 if successful, or an error value that is less 
	than or equal to 32 otherwise. The following table lists the error values. 
	The return value is cast as an HINSTANCE for backward compatibility with 
	16-bit Windows applications. It is not a true HINSTANCE, however. The 
	only thing that can be done with the returned HINSTANCE is to cast it to 
	an int and compare it with the value 32 or one of the error codes below.
	0	The operating system is out of memory or resources.
	ERROR_FILE_NOT_FOUND	The specified file was not found.
	ERROR_PATH_NOT_FOUND	The specified path was not found.
	ERROR_BAD_FORMAT	The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image).
	SE_ERR_ACCESSDENIED	The operating system denied access to the specified file.
	SE_ERR_ASSOCINCOMPLETE	The file name association is incomplete or invalid.
	SE_ERR_DDEBUSY	The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.
	SE_ERR_DDEFAIL	The DDE transaction failed.
	SE_ERR_DDETIMEOUT	The DDE transaction could not be completed because the request timed out.
	SE_ERR_DLLNOTFOUND	The specified dynamic-link library (DLL) was not found.
	SE_ERR_FNF	The specified file was not found.
	SE_ERR_NOASSOC	There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
	SE_ERR_OOM	There was not enough memory to complete the operation.
	SE_ERR_PNF	The specified path was not found.
	SE_ERR_SHARE	A sharing violation occurred.
	*/

	int nError = (int) h;
	if (nError > 32) // no error
		return;
	DisplayLastError("");

}
開發者ID:omerdagan84,項目名稱:neomem,代碼行數:33,代碼來源:Library.cpp

示例3: wcscpy_c

void ConEmuAbout::OnInfo_WhatsNew(bool bLocal)
{
	wchar_t sFile[MAX_PATH+80];
	int iExec = -1;

	if (bLocal)
	{
		wcscpy_c(sFile, gpConEmu->ms_ConEmuBaseDir);
		wcscat_c(sFile, L"\\WhatsNew-ConEmu.txt");

		if (FileExists(sFile))
		{
			iExec = (int)ShellExecute(ghWnd, L"open", sFile, NULL, NULL, SW_SHOWNORMAL);
			if (iExec >= 32)
			{
				return;
			}
		}
	}

	wcscpy_c(sFile, gsWhatsNew);

	iExec = (int)ShellExecute(ghWnd, L"open", sFile, NULL, NULL, SW_SHOWNORMAL);
	if (iExec >= 32)
	{
		return;
	}

	DisplayLastError(L"File 'WhatsNew-ConEmu.txt' not found, go to web page failed", iExec);
}
開發者ID:Alexander-Shukaev,項目名稱:ConEmu,代碼行數:30,代碼來源:AboutDlg.cpp

示例4: GetTickCount

void ConEmuAbout::OnInfo_ReportCrash(LPCWSTR asDumpWasCreatedMsg)
{
	if (nLastCrashReported)
	{
		// if previous gsReportCrash was opened less than 60 sec ago
		DWORD nLast = GetTickCount() - nLastCrashReported;
		if (nLast < 60000)
		{
			// Skip this time
			return;
		}
	}

	if (asDumpWasCreatedMsg && !*asDumpWasCreatedMsg)
	{
		asDumpWasCreatedMsg = NULL;
	}

	DWORD shellRc = (DWORD)(INT_PTR)ShellExecute(ghWnd, L"open", gsReportCrash, NULL, NULL, SW_SHOWNORMAL);
	if (shellRc <= 32)
	{
		DisplayLastError(L"ShellExecute failed", shellRc);
	}
	else if (asDumpWasCreatedMsg)
	{
		MsgBox(asDumpWasCreatedMsg, MB_OK|MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
	}

	nLastCrashReported = GetTickCount();
}
開發者ID:Alexander-Shukaev,項目名稱:ConEmu,代碼行數:30,代碼來源:AboutDlg.cpp

示例5: MultiByteToWideChar

NS_IMETHODIMP
WinCEUConvAdapter::GetMaxLength(const char * aSrc, 
                                PRInt32 aSrcLength, 
                                PRInt32 * aDestLength)
{
  if (mCodepage == -1 || aSrc == nsnull )
    return NS_ERROR_FAILURE;
  
  int count = MultiByteToWideChar(mCodepage,
                                  MB_PRECOMPOSED,
                                  aSrc,
                                  aSrcLength,
                                  NULL,
                                  NULL);
  
  if (count == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
  {
    // fall back on the current system Windows "ANSI" code page
    
    count = MultiByteToWideChar(CP_ACP,
                                MB_PRECOMPOSED,
                                aSrc,
                                aSrcLength,
                                NULL,
                                NULL);
  }
  
#ifdef ALERT_DBG  
  if (count == 0)
    DisplayLastError("MultiByteToWideChar (0)");
#endif
  
  *aDestLength = count;
  return NS_OK;
}
開發者ID:MozillaOnline,項目名稱:gecko-dev,代碼行數:35,代碼來源:nsWinCEUConvService.cpp

示例6: wcscpy_c

bool CConEmuUpdate::CanUpdateInstallation()
{
	if (UpdateDownloadSetup() == 1)
	{
		// Если через Setupper - то msi сам разберется и ругнется когда надо
		return true;
	}

	// Раз дошли сюда - значит ConEmu был просто "распакован"

	if (IsUserAdmin())
	{
		// ConEmu запущен "Под администратором", проверки не нужны
		return true;
	}

	wchar_t szTestFile[MAX_PATH*2];
	wcscpy_c(szTestFile, gpConEmu->ms_ConEmuExeDir);
	wcscat_c(szTestFile, L"\\ConEmuUpdate.check");

	HANDLE hFile = CreateFile(szTestFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_TEMPORARY, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		DWORD nErr = GetLastError();
		wcscpy_c(szTestFile, L"Can't update installation folder!\r\n");
		wcscat_c(szTestFile, gpConEmu->ms_ConEmuExeDir);
		DisplayLastError(szTestFile, nErr);
		return false;
	}
	CloseHandle(hFile);
	DeleteFile(szTestFile);

	// OK
	return true;
}
開發者ID:NickLatysh,項目名稱:conemu,代碼行數:35,代碼來源:Update.cpp

示例7: GetSysColor

void CTabPanelWin::ShowToolbar(bool bShow)
{
	if (bShow)
	{
		if (!IsToolbarCreated() && (CreateToolbar() != NULL))
		{
			REBARBANDINFO rbBand = {80}; // не используем size, т.к. приходит "новый" размер из висты и в XP обламываемся

			rbBand.fMask  = RBBIM_SIZE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_ID | RBBIM_STYLE | RBBIM_COLORS;
			rbBand.fStyle = RBBS_CHILDEDGE | RBBS_FIXEDSIZE | RBBS_VARIABLEHEIGHT;
			rbBand.clrBack = GetSysColor(COLOR_BTNFACE);
			rbBand.clrFore = GetSysColor(COLOR_BTNTEXT);

			SIZE sz = {0,0};
			SendMessage(mh_Toolbar, TB_GETMAXSIZE, 0, (LPARAM)&sz);

			// Set values unique to the band with the toolbar.
			rbBand.wID        = 2;
			rbBand.hwndChild  = mh_Toolbar;
			rbBand.cx = rbBand.cxMinChild = rbBand.cxIdeal = mn_LastToolbarWidth = sz.cx;
			rbBand.cyChild = rbBand.cyMinChild = rbBand.cyMaxChild = sz.cy + mn_ThemeHeightDiff;

			// Add the band that has the toolbar.
			if (!SendMessage(mh_Rebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand))
			{
				DisplayLastError(_T("Can't initialize rebar (toolbar)"));
			}
		}
	}
	else
	{
		_ASSERTEX(bShow);
	}
}
開發者ID:martell,項目名稱:ConEmu,代碼行數:34,代碼來源:TabCtrlWin.cpp

示例8: SetForegroundWindow

void CEFindDlg::FindTextDialog()
{
	if (mh_FindDlg && IsWindow(mh_FindDlg))
	{
		SetForegroundWindow(mh_FindDlg);
		return;
	}

	CVConGuard VCon;
	CRealConsole* pRCon = (CVConGroup::GetActiveVCon(&VCon) >= 0) ? VCon->RCon() : NULL;

	// Создаем диалог поиска только для консольных приложений
	if (!pRCon || (pRCon->GuiWnd() && !pRCon->isBufferHeight()) || !pRCon->GetView())
	{
		//DisplayLastError(L"No RealConsole, nothing to find");
		return;
	}

	gpConEmu->SkipOneAppsRelease(true);
	
	mh_FindDlg = CreateDialogParam((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_FIND), ghWnd, findTextProc, 0/*Param*/);
	if (!mh_FindDlg)
	{
		DisplayLastError(L"Can't create Find text dialog", GetLastError());
	}
}
開發者ID:G-VAR,項目名稱:ConEmu,代碼行數:26,代碼來源:FindDlg.cpp

示例9: WideCharToMultiByte

NS_IMETHODIMP
WinCEUConvAdapter::Convert(const PRUnichar * aSrc, 
                           PRInt32 * aSrcLength, 
                           char * aDest, 
                           PRInt32 * aDestLength)
{
  if (mCodepage == -1)
    return NS_ERROR_FAILURE;
  
  char * defaultChar = "?";
  int count = WideCharToMultiByte(mCodepage,
                                  0,
                                  aSrc,
                                  *aSrcLength,
                                  aDest,
                                  *aDestLength,
                                  defaultChar,
                                  NULL);
  
#ifdef ALERT_DBG
  if (count == 0)
    DisplayLastError("WideCharToMultiByte");
#endif
  
  *aSrcLength = count;
  *aDestLength = count;
  
  return NS_OK;
}
開發者ID:MozillaOnline,項目名稱:gecko-dev,代碼行數:29,代碼來源:nsWinCEUConvService.cpp

示例10: MyOpenClipboard

bool MyOpenClipboard(LPCWSTR asAction)
{
	_ASSERTE(gnMyClipboardOpened==0 || gnMyClipboardOpened==1);

	if (gnMyClipboardOpened > 0)
	{
		InterlockedIncrement(&gnMyClipboardOpened);
		return true;
	}

	BOOL lbRc;
	int iMaxTries = 100;

	// Open Windows' clipboard
	while (!(lbRc = OpenClipboard((ghWnd && IsWindow(ghWnd)) ? ghWnd : NULL)) && (iMaxTries-- > 0))
	{
		DWORD dwErr = GetLastError();

		wchar_t szCode[32]; _wsprintf(szCode, SKIPCOUNT(szCode) L", Code=%u", dwErr);
		wchar_t* pszMsg = lstrmerge(L"OpenClipboard failed (", asAction, L")", szCode);
		LogString(pszMsg);
		int iBtn = DisplayLastError(pszMsg, dwErr, MB_RETRYCANCEL|MB_ICONSTOP);
		SafeFree(pszMsg);

		if (iBtn != IDRETRY)
			return false;
	}

	InterlockedIncrement(&gnMyClipboardOpened);
	_ASSERTE(gnMyClipboardOpened==1);

	LogString(L"OpenClipboard succeeded");
	return true;
}
開發者ID:ForNeVeR,項目名稱:ConEmu,代碼行數:34,代碼來源:MyClipboard.cpp

示例11: switch

bool CDlgItemHelper::ProcessHyperlinkCtrl(HWND hDlg, WORD nCtrlId)
{
	if (!isHyperlinkCtrl(nCtrlId))
	{
		return false;
	}

	CEStr lsUrl;

	switch (nCtrlId)
	{
	case stConEmuUrl:
		lsUrl = gsHomePage;
		break;
	case stHomePage:
		lsUrl = gsFirstStart;
		break;
	default:
		if (GetString(hDlg, nCtrlId, &lsUrl.ms_Val) <= 0)
			return false;
		if ((0 != wcsncmp(lsUrl, L"http://", 7))
			&& (0 != wcsncmp(lsUrl, L"https://", 8))
			) return false;
	}

	DWORD shellRc = (DWORD)(INT_PTR)ShellExecute(ghWnd, L"open", lsUrl, NULL, NULL, SW_SHOWNORMAL);
	if (shellRc <= 32)
	{
		DisplayLastError(L"ShellExecute failed", shellRc);
		return false;
	}

	return true;
}
開發者ID:2asoft,項目名稱:ConEmu,代碼行數:34,代碼來源:DlgItemHelper.cpp

示例12: _ASSERTE

// Открыть диалог с подтверждением параметров создания/закрытия/пересоздания консоли
int CRecreateDlg::RecreateDlg(RConStartArgsEx* apArgs, bool abDontAutoSelCmd /*= false*/)
{
	if (!this)
	{
		_ASSERTE(this);
		return IDCANCEL;
	}

	mb_DontAutoSelCmd = abDontAutoSelCmd;

	if (mh_Dlg && IsWindow(mh_Dlg))
	{
		DisplayLastError(L"Close previous 'Create dialog' first, please!", -1);
		return IDCANCEL;
	}

	DontEnable de;

	gpConEmu->SkipOneAppsRelease(true);

	//if (!gpConEmu->mh_RecreatePasswFont)
	//{
	//	gpConEmu->mh_RecreatePasswFont = CreateFont(

	//}

	mn_DlgRc = IDCANCEL;
	mp_Args = apArgs;

	mh_Parent = (apArgs->aRecreate == cra_EditTab && ghOpWnd) ? ghOpWnd : ghWnd;

	#ifdef _DEBUG
	if ((mh_Parent == ghWnd) && gpConEmu->isIconic())
	{
		_ASSERTE(FALSE && "Window must be shown before dialog!");
	}
	#endif

	InitVars();

	bool bPrev = gpConEmu->SetSkipOnFocus(true);
	CDpiForDialog::Create(mp_DpiAware);
	// Modal dialog (CreateDialog)
	int nRc = CDynDialog::ExecuteDialog(IDD_RESTART, mh_Parent, RecreateDlgProc, (LPARAM)this);
	UNREFERENCED_PARAMETER(nRc);
	gpConEmu->SetSkipOnFocus(bPrev);

	FreeVars();

	//if (gpConEmu->mh_RecreatePasswFont)
	//{
	//	DeleteObject(gpConEmu->mh_RecreatePasswFont);
	//	gpConEmu->mh_RecreatePasswFont = NULL;
	//}

	gpConEmu->SkipOneAppsRelease(false);

	return mn_DlgRc;
}
開發者ID:davgit,項目名稱:ConEmu,代碼行數:60,代碼來源:Recreate.cpp

示例13: DisplayLastError

void ConEmuAbout::OnInfo_ReportBug()
{
	DWORD shellRc = (DWORD)(INT_PTR)ShellExecute(ghWnd, L"open", gsReportBug, NULL, NULL, SW_SHOWNORMAL);
	if (shellRc <= 32)
	{
		DisplayLastError(L"ShellExecute failed", shellRc);
	}
}
開發者ID:Alexander-Shukaev,項目名稱:ConEmu,代碼行數:8,代碼來源:AboutDlg.cpp

示例14: LoadResources

void ConEmuAbout::DonateBtns_Add(HWND hDlg, int AlignLeftId, int AlignVCenterId)
{
	if (!m_Btns[0].pImg)
		LoadResources();

	RECT rcLeft = {}, rcTop = {};
	HWND hCtrl;

	hCtrl = GetDlgItem(hDlg, AlignLeftId);
	GetWindowRect(hCtrl, &rcLeft);
	MapWindowPoints(NULL, hDlg, (LPPOINT)&rcLeft, 2);
	hCtrl = GetDlgItem(hDlg, AlignVCenterId);
	GetWindowRect(hCtrl, &rcTop);
	int nPreferHeight = rcTop.bottom - rcTop.top;
	MapWindowPoints(NULL, hDlg, (LPPOINT)&rcTop, 2);

	#ifdef _DEBUG
	DpiValue dpi;
	CDpiAware::QueryDpiForWindow(hDlg, &dpi);
	#endif

	int X = rcLeft.left;

	for (size_t i = 0; i < countof(m_Btns); i++)
	{
		if (!m_Btns[i].pImg)
			continue; // Image was failed

		TODO("Вертикальное центрирование по объекту AlignVCenterId");

		int nDispW = 0, nDispH = 0;
		if (!m_Btns[i].pImg->GetSizeForHeight(nPreferHeight, nDispW, nDispH))
		{
			_ASSERTE(FALSE && "Image not available for dpi?");
			continue; // Image was failed?
		}
		_ASSERTE(nDispW>0 && nDispH>0);
		int nY = rcTop.top + ((rcTop.bottom - rcTop.top - nDispH + 1) / 2);

		hCtrl = CreateWindow(L"STATIC", m_Btns[i].ResId,
			WS_CHILD|WS_VISIBLE|SS_NOTIFY|SS_OWNERDRAW,
			X, nY, nDispW, nDispH,
			hDlg, (HMENU)m_Btns[i].nCtrlId, g_hInstance, NULL);

		#ifdef _DEBUG
		if (!hCtrl)
			DisplayLastError(L"Failed to create image button control");
		#endif

		//X += nDispW + (10 * dpi.Ydpi / 96);
		X += nDispW + (nDispH / 3);
	}

	RegisterTip(hDlg);

	UNREFERENCED_PARAMETER(hCtrl);
}
開發者ID:Alexander-Shukaev,項目名稱:ConEmu,代碼行數:57,代碼來源:AboutDlg.cpp

示例15: szUrl

void ConEmuAbout::OnInfo_OnlineWiki(LPCWSTR asPageName /*= NULL*/)
{
	CEStr szUrl(lstrmerge(CEWIKIBASE, asPageName ? asPageName : L"TableOfContents", L".html"));
	DWORD shellRc = (DWORD)(INT_PTR)ShellExecute(ghWnd, L"open", szUrl, NULL, NULL, SW_SHOWNORMAL);
	if (shellRc <= 32)
	{
		DisplayLastError(L"ShellExecute failed", shellRc);
	}
}
開發者ID:Alexander-Shukaev,項目名稱:ConEmu,代碼行數:9,代碼來源:AboutDlg.cpp


注:本文中的DisplayLastError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。