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


C++ CConsole::ReadLine方法代码示例

本文整理汇总了C++中CConsole::ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C++ CConsole::ReadLine方法的具体用法?C++ CConsole::ReadLine怎么用?C++ CConsole::ReadLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CConsole的用法示例。


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

示例1: main


//.........这里部分代码省略.........

	TCHAR *pchCommand;

  pchCommand = Console.Init(INPUT_BUFFER_SIZE,10);
  if (pchCommand == NULL)
  {
    _ftprintf(stderr,_T("Cannot initialize console.\n"));
    nRetCode = 1;
    goto Exit;
  }

	Console.SetReplaceCompletionCallback(CompletionCallback);

	WORD wOldConsoleAttribute;
	if (!Console.GetTextAttribute(wOldConsoleAttribute)) goto Abort;

	Console.SetTitle(_T("Registry Explorer"));
	Console.SetTextAttribute(pSettings->GetNormalTextAttributes());

	VERIFY(SetConsoleCtrlHandler((PHANDLER_ROUTINE)HandlerRoutine,TRUE));

	if (!Console.Write(HELLO_MSG
	//(_L(__TIMESTAMP__))
	)) goto Abort;

  //Tree.SetDesiredOpenKeyAccess(KEY_READ);

  hr = pPrompt->SetPrompt(pSettings->GetPrompt());
  if (FAILED(hr))
  {
    _ftprintf(stderr,_T("Cannot initialize prompt. Error is 0x%X.\n"),(unsigned int)hr);
    goto Abort;
  }

GetCommand:
	// prompt
	// TODO: make prompt user-customizable
	Console.EnableWrite();
	pPrompt->ShowPrompt(Console);
	Console.FlushInputBuffer();

	blnCommandExecutionInProgress = FALSE;

	// Set command line color
  Console.SetTextAttribute(pSettings->GetCommandTextAttributes());
	if (!Console.ReadLine())
    goto Abort;

	// Set normal color
	Console.SetTextAttribute(pSettings->GetNormalTextAttributes());

	Console.BeginScrollingOperation();
	blnCommandExecutionInProgress = TRUE;

	// Parse command line (1st step - convert to multi sz)
	Parser.SetArgumentList(pchCommand);

	int nCommandReturnValue;
	switch(CommandsList.Execute(Parser,nCommandReturnValue))
	{
	case -1:	// not recognized command
		{
			Parser.ResetArgumentIteration();
			TCHAR *pchCommandItself = Parser.GetNextArgument();
			size_t cmdlen = _tcslen(pchCommandItself);
			if ((!cmdlen)||
				(pchCommandItself[cmdlen-1] != _T('\\'))||
				(Parser.GetNextArgument())||
				(!Tree.ChangeCurrentKey(pchCommandItself)))
			{
				Console.Write(_T("Unknown command \""));
				Console.Write(pchCommandItself);
				Console.Write(_T("\"\n"));
			}
		}
	case -2:	// empty line
		goto GetCommand;
	case 0:	// exit command
		nRetCode = 0;
		Console.SetTextAttribute(wOldConsoleAttribute);
		goto Exit;
	default:
		Console.Write(_T("\n"));
		goto GetCommand;
	}

Abort:
	_ftprintf(stderr,_T("Abnormal program termination.\nPlease report bugs to ") EMAIL _T("\n"));
	nRetCode = 1;

Exit:

  if (pSettings)
    delete pSettings;

  if (pPrompt)
    delete pPrompt;

	return nRetCode;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:101,代码来源:RegistryExplorer.cpp


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