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


C++ GetConsoleMode函数代码示例

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


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

示例1: rtStrmIsConsoleUnlocked

/**
 * Check if the stream is for a Window console.
 *
 * @returns true / false.
 * @param   pStream             The stream.
 * @param   phCon               Where to return the console handle.
 */
static bool rtStrmIsConsoleUnlocked(PRTSTREAM pStream, HANDLE *phCon)
{
    int fh = fileno(pStream->pFile);
    if (isatty(fh))
    {
        DWORD dwMode;
        HANDLE hCon = (HANDLE)_get_osfhandle(fh);
        if (GetConsoleMode(hCon, &dwMode))
        {
            *phCon = hCon;
            return true;
        }
    }
    return false;
}
开发者ID:eaas-framework,项目名称:virtualbox,代码行数:22,代码来源:stream.cpp

示例2: win_get_console_mode

CAMLprim value win_get_console_mode (value unit)
{
  DWORD mode;
  BOOL res;

  init_conin ();

  res = GetConsoleMode (conin, &mode);
  if (res == 0) {
    win32_maperr (GetLastError ());
    uerror("get_console_mode", Nothing);
  }

  return (Val_int (mode));
}
开发者ID:Phylliade,项目名称:Unison,代码行数:15,代码来源:system_win_stubs.c

示例3: SetFileApisToOEM

void TThreads::resume() {
   if (!inited) {
      SetFileApisToOEM();
      chandle[cnInput]  = GetStdHandle(STD_INPUT_HANDLE);
      chandle[cnOutput] = GetStdHandle(STD_OUTPUT_HANDLE);
      GetConsoleCursorInfo(chandle[cnOutput], &crInfo);
      GetConsoleScreenBufferInfo(chandle[cnOutput], &sbInfo);
      GetConsoleMode(chandle[cnInput],&consoleMode);
      consoleMode &= ~(ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_WINDOW_INPUT);
      SetConsoleMode(chandle[cnInput],consoleMode);

      evpending = 0;
      inited = 1;
   }
}
开发者ID:OS2World,项目名称:SYSTEM-LOADER-QSINIT,代码行数:15,代码来源:os2handl.cpp

示例4: OnPeekConsoleInputA

BOOL WINAPI OnPeekConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead)
{
	//typedef BOOL (WINAPI* OnPeekConsoleInputA_t)(HANDLE,PINPUT_RECORD,DWORD,LPDWORD);
	SUPPRESSORIGINALSHOWCALL;
	ORIGINAL_KRNL(PeekConsoleInputA);
	//if (gpFarInfo && bMainThread)
	//	TouchReadPeekConsoleInputs(1);
	BOOL lbRc = FALSE;

	if (ph && ph->PreCallBack)
	{
		SETARGS4(&lbRc,hConsoleInput,lpBuffer,nLength,lpNumberOfEventsRead);

		// Если функция возвращает FALSE - реальное чтение не будет вызвано
		if (!ph->PreCallBack(&args))
			return lbRc;
	}

	PreReadConsoleInput(hConsoleInput, rcif_Ansi|rcif_Peek|rcif_LLInput);

	//#ifdef USE_INPUT_SEMAPHORE
	//DWORD nSemaphore = ghConInSemaphore ? WaitForSingleObject(ghConInSemaphore, INSEMTIMEOUT_READ) : 1;
	//_ASSERTE(nSemaphore<=1);
	//#endif

#if 0
	DWORD nMode = 0; GetConsoleMode(hConsoleInput, &nMode);
#endif

	lbRc = F(PeekConsoleInputA)(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead);

	PostReadConsoleInput(hConsoleInput, rcif_Ansi|rcif_Peek|rcif_LLInput);

	//#ifdef USE_INPUT_SEMAPHORE
	//if ((nSemaphore == WAIT_OBJECT_0) && ghConInSemaphore) ReleaseSemaphore(ghConInSemaphore, 1, NULL);
	//#endif

	if (ph && ph->PostCallBack)
	{
		SETARGS4(&lbRc,hConsoleInput,lpBuffer,nLength,lpNumberOfEventsRead);
		ph->PostCallBack(&args);
	}

	if (lbRc && lpNumberOfEventsRead && *lpNumberOfEventsRead && lpBuffer)
		OnPeekReadConsoleInput('P', 'A', hConsoleInput, lpBuffer, *lpNumberOfEventsRead);

	return lbRc;
}
开发者ID:1833183060,项目名称:ConEmu,代码行数:48,代码来源:hkConsoleInput.cpp

示例5: CON_Init

/*
==================
CON_Init
==================
*/
void CON_Init( void )
{
	CONSOLE_CURSOR_INFO        curs;
	CONSOLE_SCREEN_BUFFER_INFO info;
	int                        i;

	// handle Ctrl-C or other console termination
	SetConsoleCtrlHandler( CON_CtrlHandler, TRUE );

	qconsole_hin = GetStdHandle( STD_INPUT_HANDLE );

	if ( qconsole_hin == INVALID_HANDLE_VALUE )
	{
		return;
	}

	qconsole_hout = GetStdHandle( STD_OUTPUT_HANDLE );

	if ( qconsole_hout == INVALID_HANDLE_VALUE )
	{
		return;
	}

	GetConsoleMode( qconsole_hin, &qconsole_orig_mode );

	// allow mouse wheel scrolling
	SetConsoleMode( qconsole_hin,
	                qconsole_orig_mode & ~ENABLE_MOUSE_INPUT );

	FlushConsoleInputBuffer( qconsole_hin );

	GetConsoleScreenBufferInfo( qconsole_hout, &info );
	qconsole_attrib = info.wAttributes;

	SetConsoleTitle( "Daemon Console" );

	// make cursor invisible
	GetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo );
	curs.dwSize = 1;
	curs.bVisible = FALSE;
	SetConsoleCursorInfo( qconsole_hout, &curs );

	// initialize history
	for ( i = 0; i < QCONSOLE_HISTORY; i++ )
	{
		qconsole_history[ i ][ 0 ] = '\0';
	}
}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:53,代码来源:con_win32.c

示例6: disable_quick_edit

static void
disable_quick_edit(void)
{
    DWORD mode = 0;
    HANDLE console = GetStdHandle(STD_INPUT_HANDLE);

    // Get current console mode
    if (console == NULL || !GetConsoleMode(console, &mode)) {
        return;
    }

    // Clear the quick edit bit in the mode flags
    mode &= ~ENABLE_QUICK_EDIT;
    mode |= ENABLE_EXTENDED_FLAGS;
    SetConsoleMode(console, mode);
}
开发者ID:SChen5-Quest,项目名称:simple-obfs,代码行数:16,代码来源:win32.c

示例7: GetStdHandle

ConsoleMedia::ConsoleMedia()
{
    m_bRedirectedToFile = true;

    m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    if (m_hConsole == NULL)
    {
        if (!AllocConsole() //|| !SetConsoleTitle(_T("Log"))
            || (m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE)) == NULL)
            return;
    }
    GetConsoleScreenBufferInfo(m_hConsole, &m_info);

    DWORD t;
    m_bRedirectedToFile = GetConsoleMode(m_hConsole, &t) == FALSE;
}
开发者ID:Blonder,项目名称:TortoiseGit,代码行数:16,代码来源:log.cpp

示例8: alloc_console

void alloc_console() {
	CONSOLE_SCREEN_BUFFER_INFO coninfo;
	HANDLE hStdin = GetStdHandle (STD_INPUT_HANDLE);
	DWORD lpMode;

	AllocConsole ();
	GetConsoleMode (hStdin, &lpMode);
	SetConsoleMode (hStdin, lpMode & (~ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT));
	GetConsoleScreenBufferInfo (hStdin, &coninfo);
	coninfo.dwSize.Y = 4096;
	SetConsoleScreenBufferSize (hStdin, coninfo.dwSize);

	freopen ("conin$", "r", stdin);
	freopen ("conout$", "w", stdout);
	freopen ("conout$", "w", stderr);
}
开发者ID:aronsky,项目名称:radare2,代码行数:16,代码来源:libr2.c

示例9: GetConsoleWindow

void console_widget_NT_t::init_new_console()
{	
	allocated_console = false;

	saved_hwnd = GetConsoleWindow();
	if (saved_hwnd == (HWND)0) {
		AllocConsole();
		allocated_console = true;
		saved_hwnd = GetConsoleWindow();
	}

	saved_input = GetStdHandle(STD_INPUT_HANDLE);
	saved_output = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleCursorInfo(saved_output, &saved_cursor);
	GetConsoleMode(saved_input, &saved_mode);
}
开发者ID:matt81093,项目名称:Original-Colinux,代码行数:16,代码来源:widget.cpp

示例10: rktio_system_fd_is_terminal

int rktio_system_fd_is_terminal(rktio_t *rktio, intptr_t fd)
{
#ifdef RKTIO_SYSTEM_UNIX
  return isatty(fd);
#endif
#ifdef RKTIO_SYSTEM_WINDOWS
  if (GetFileType((HANDLE)fd) == FILE_TYPE_CHAR) {
    DWORD mode;
    if (GetConsoleMode((HANDLE)fd, &mode))
      return 1;
    else
      return 0;
  } else
    return 0;
#endif
}
开发者ID:97jaz,项目名称:racket,代码行数:16,代码来源:rktio_fd.c

示例11: SLMprintf

int
SLMprintf(
    WCHAR *szformat, ...)
{
    va_list marker;
    int iret = 0;
    int count;
    long cbWritten;
    DWORD dwMode;

    va_start(marker, szformat);
    count = vswprintf(szText, szformat, marker);

    if (!bUnicode) {
        memset (chBuf, 0, sizeof(chBuf));
#ifdef _WIN32
        WideCharToMultiByte (CP_ACP, 0, szText, count, chBuf, sizeof(chBuf), NULL, NULL);
#else
        wcstombs (chBuf, szText, sizeof(chBuf));
#endif
        iret = printf("%s", chBuf);
        if (fCkSum)
            CheckSum(chBuf, strlen(chBuf));
    }
    else {
#ifdef _WIN32
        if (GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdout)), &dwMode)) {
            WriteConsoleW ((HANDLE)_get_osfhandle(_fileno(stdout)),
                           szText,
                           count,
                           &cbWritten,
                           NULL);
            iret = cbWritten;
        }
        else
            iret = wprintf(szText);
#else
        iret = wprintf(szText);
#endif
        if (fCkSum)
            CheckSum((char *)szText, wcslen(szText) * sizeof(WCHAR));
    }

    va_end(marker);

    return (iret);
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:47,代码来源:slmdiff.c

示例12: csync_getpass

int csync_getpass(const char *prompt,
                char *buf,
                size_t len,
                int echo,
                int verify,
                void *userdata
               ) {
    /* unused variables */
    (void) userdata;

    HANDLE h;
    DWORD mode = 0;
    int ok;

    /* fgets needs at least len - 1 */
    if (prompt == NULL || buf == NULL || len < 2) {
        return -1;
    }

    /* get stdin and mode */
    h = GetStdHandle(STD_INPUT_HANDLE);
    if (!GetConsoleMode(h, &mode)) {
        return -1;
    }

    /* disable echo */
    if (!echo) {
        if (!SetConsoleMode(h, mode & ~ENABLE_ECHO_INPUT)) {
            return -1;
        }
    }

    ok = csync_gets(prompt, buf, len, verify);

    /* reset echo */
    SetConsoleMode(h, mode);

    if (!ok) {
        memset (buf, '\0', len);
        return -1;
    }

    /* force termination */
    buf[len - 1] = '\0';

    return 0;
}
开发者ID:OpenDataSpace,项目名称:ocsync,代码行数:47,代码来源:csync_auth.c

示例13: ChangeMode

/* ************************************
* VOID ChangeMode( HANDLE hStdin, HANDLE hStdout)
* 功能	改变控制台的模式,关闭ENABLE_LINE_INPUT和ENABLE_ECHO_INPUT
* 参数	HANDLE hStdin, HANDLE hStdout,句柄
**************************************/
VOID ChangeMode( HANDLE hStdin, HANDLE hStdout)
{
		LPSTR lpszPrompt = "Mode changeed Type any key, or q to quit: ";
		CHAR chBuffer[256];

	DWORD fdwMode, fdwOldMode;
	DWORD cRead,cWritten;
	// 获取当前模式
	if (! GetConsoleMode(hStdin, &fdwOldMode)) 
	{
		MessageBox(NULL, "GetConsoleMode", "Console Error", MB_OK); 
		return;
	}
	// 修改模式并重新设置
	fdwMode = fdwOldMode & 
		~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); 
	if (! SetConsoleMode(hStdin, fdwMode)) 
	{
		MessageBox(NULL, "SetConsoleMode", "Console Error", MB_OK); 
		return;
	}
	// 换行
	NewLine();
	// 循环等待输入并处理
	while (1) 
	{ 
		if (! WriteFile( hStdout, 
			lpszPrompt,  lstrlen(lpszPrompt), 
			&cWritten, NULL) )
		{
			MyErrorExit("WriteFile");
			return;
		}

		if (! ReadFile(hStdin, chBuffer, 1, &cRead, NULL)) 
			break; 
		if (chBuffer[0] == '\r')
			NewLine();
		else if (! WriteFile(hStdout, chBuffer, cRead, 
			&cWritten, NULL)) break;
		else
			NewLine();
		if (chBuffer[0] == 'q') break; // 输入q,退出 
	} 
	// 恢复模式
	SetConsoleMode(hStdin, fdwOldMode);
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:52,代码来源:Console.c

示例14: r_line_new

R_API RCons *r_cons_new () {
	I.line = r_line_new ();
	I.event_interrupt = NULL;
	I.blankline = R_TRUE;
	I.heightfix = 0;
	I.widthfix = 0;
	I.event_resize = NULL;
	I.data = NULL;
	I.event_data = NULL;
	I.is_interactive = R_TRUE;
	I.noflush = R_FALSE;
	I.force_rows = 0;
	I.force_columns = 0;
	I.fdin = stdin;
	I.fdout = 1;
	I.breaked = R_FALSE;
	//I.lines = 0;
	I.buffer = NULL;
	I.buffer_sz = 0;
	I.buffer_len = 0;
	r_cons_get_size (NULL);
	I.num = NULL;
#if EMSCRIPTEN
	/* do nothing here :? */
#elif __UNIX__
	tcgetattr (0, &I.term_buf);
	memcpy (&I.term_raw, &I.term_buf, sizeof (I.term_raw));
	I.term_raw.c_iflag &= ~(BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
	I.term_raw.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
	I.term_raw.c_cflag &= ~(CSIZE|PARENB);
	I.term_raw.c_cflag |= CS8;
	I.term_raw.c_cc[VMIN] = 1; // Solaris stuff hehe
	signal (SIGWINCH, resize);
#elif __WINDOWS__
	h = GetStdHandle (STD_INPUT_HANDLE);
	GetConsoleMode (h, (PDWORD) &I.term_buf);
	I.term_raw = 0;
	if (!SetConsoleCtrlHandler ((PHANDLER_ROUTINE)__w32_control, TRUE))
		eprintf ("r_cons: Cannot set control console handler\n");
#endif
	I.pager = NULL; /* no pager by default */
	I.truecolor = 0;
	r_cons_pal_init (NULL);
	r_cons_rgb_init ();
	r_cons_reset ();
	return &I;
}
开发者ID:sstjohn,项目名称:radare2,代码行数:47,代码来源:cons.c

示例15: isatty

/* MS runtime's isatty returns non-zero for any character device,
   including the null device, which is not what we want.  */
int
isatty (int fd)
{
  HANDLE fh = (HANDLE) _get_osfhandle (fd);
  DWORD con_mode;

  if (fh == INVALID_HANDLE_VALUE)
    {
      errno = EBADF;
      return 0;
    }
  if (GetConsoleMode (fh, &con_mode))
    return 1;

  errno = ENOTTY;
  return 0;
}
开发者ID:mirror,项目名称:make,代码行数:19,代码来源:posixfcn.c


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