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


C++ SetConsoleMode函数代码示例

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


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

示例1: enableRawMode

static int enableRawMode(struct current *current) {
    DWORD n;
    INPUT_RECORD irec;

    current->outh = GetStdHandle(STD_OUTPUT_HANDLE);
    current->inh = GetStdHandle(STD_INPUT_HANDLE);

    if (!PeekConsoleInput(current->inh, &irec, 1, &n)) {
        return -1;
    }
    if (getWindowSize(current) != 0) {
        return -1;
    }
    if (GetConsoleMode(current->inh, &orig_consolemode)) {
        SetConsoleMode(current->inh, ENABLE_PROCESSED_INPUT);
    }
    return 0;
}
开发者ID:h3rald,项目名称:ickle,代码行数:18,代码来源:liblinenoise.c

示例2: installsighandler

static void installsighandler()
{
	#ifndef _WIN32
		signal(SIGHUP,sighandler);
		signal(SIGUSR1,sighandler);
		signal(SIGPIPE,sighandler);
	#endif
	signal(SIGINT,sighandler);
	#ifdef _WIN32
		SetConsoleCtrlHandler(ConsoleCtrlHandler,true);
		HANDLE hs=GetStdHandle(STD_INPUT_HANDLE);
		DWORD mode;
		if (GetConsoleMode(hs,&mode)) {
			mode|=ENABLE_PROCESSED_INPUT;
			SetConsoleMode(hs,mode);
		};
	#endif
}
开发者ID:vattay,项目名称:waste,代码行数:18,代码来源:srvmain.cpp

示例3: ConsoleInit

extern void ConsoleInit(void)
{
	CONSOLE_CURSOR_INFO cci;
	int i;
	
	/* コンソール標準出力画面のハンドルを取得。プログラム終了時にアクティブ化 */	
	m_hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

	if (m_hStdOut == INVALID_HANDLE_VALUE)
	{
		fprintf(stderr, "error: Console: InitConsole: hStdOut: %ld\n", GetLastError());
	}
	
	/* コンソールスクリーンの作成と初期化 */
	for (i=0; i<NUM_SCREEN_MAX; i++)
	{
		m_hScreen[i] = CreateConsoleScreenBuffer(
			GENERIC_READ | GENERIC_WRITE,
			0,
			NULL,
			CONSOLE_TEXTMODE_BUFFER,
			NULL
		);
		if (m_hScreen[i] == INVALID_HANDLE_VALUE)
		{
			fprintf(stderr, "error: Console: InitConsole: %ld\n", GetLastError());
		}
		
		/* カーソル情報の初期化 */
		GetConsoleCursorInfo(m_hScreen[i], &cci);
		cci.bVisible = FALSE;// カーソルの非表示
		SetConsoleCursorInfo(m_hScreen[i], &cci);
		
		/* ウィンドウサイズの初期化 */
		SetWindowSize(m_hScreen[i], NUM_WINDOW_HEIGHT, NUM_WINDOW_WIDTH);
		
		/* コンソールモードの初期化 */
		SetConsoleMode(m_hScreen[i], ENABLE_PROCESSED_OUTPUT);
	}
	m_hScreenIndex	= 0;
	m_hOut			= m_hScreen[1];
    m_hWork			= m_hScreen[0];
	SetConsoleActiveScreenBuffer(m_hOut);// 出力スクリーンをアクティブ化
}
开发者ID:uranosan,项目名称:noplan-part58,代码行数:44,代码来源:Console.c

示例4: oss_con_init

/* initialize console */
void oss_con_init(void)
{
    DWORD new_console_mode;
    OSVERSIONINFO ver_info;
    
    /* get the console input and output handles */
    G_out_bufhdl = GetStdHandle(STD_OUTPUT_HANDLE);
    G_in_bufhdl = GetStdHandle(STD_INPUT_HANDLE);

    /* get the original console mode so we can restore it when we're done */
    GetConsoleMode(G_out_bufhdl, &S_orig_console_out_mode);
    GetConsoleMode(G_in_bufhdl, &S_orig_console_in_mode);

    /* if we're in 'plain' mode, don't change the console mode */
    if (os_f_plain)
        return;

    /* start with the original console mode bits */
    new_console_mode = S_orig_console_out_mode;

    /*
     *   Turn off wrapping when writing at the end of the line - the
     *   automatic wrapping screws up our scrolling, and we don't need it
     *   anyway since we keep track of all of our cursor positioning
     *   ourselves, hence it's easier if we just turn this feature off 
     */
    new_console_mode &= ~ENABLE_WRAP_AT_EOL_OUTPUT;

    /* 
     *   If we're on a 95 derivative (95, 98, ME), also clear the "processed
     *   output" flag.  This flag is necessary on NT for proper character
     *   set handling, but is not on 95/98/ME; and if that flag isn't
     *   cleared on 95/98/ME, clearing the wrap-at-eol flag has no effect.
     *   So, we must clear this flag on 95/98/ME, but we must leave it
     *   enabled on NT.  (What a pain.)
     */
    ver_info.dwOSVersionInfoSize = sizeof(ver_info);
    GetVersionEx(&ver_info);
    if (ver_info.dwPlatformId != VER_PLATFORM_WIN32_NT)
        new_console_mode &= ~ENABLE_PROCESSED_OUTPUT;

    /* set the new console mode */
    SetConsoleMode(G_out_bufhdl, new_console_mode);
}
开发者ID:BPaden,项目名称:garglk,代码行数:45,代码来源:ossdos32.c

示例5: InitializeTerminal

/*--------------------------------------------------------------------------*/
void InitializeTerminal(void)
{
    if (!Win32InputStream)
    {
        Win32InputStream = GetStdHandle(STD_INPUT_HANDLE);
        GetConsoleMode(Win32InputStream, &OldWin32Mode);
        SetConsoleMode(Win32InputStream, ENABLE_PROCESSED_INPUT);
    }

    if (!Win32OutputStream)
    {
        Win32OutputStream = GetStdHandle(STD_OUTPUT_HANDLE);
    }

    setFocusOnConsole();

    SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE );

}
开发者ID:ZhanlinWang,项目名称:scilab,代码行数:20,代码来源:TermConsole.c

示例6: 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;
	qconsole_backgroundAttrib = qconsole_attrib & (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);

	SetConsoleTitle("Dedicated Server 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';

	// set text color to white
	SetConsoleTextAttribute(qconsole_hout, CON_ColorCharToAttrib(COLOR_WHITE));
}
开发者ID:raynorpat,项目名称:cake,代码行数:48,代码来源:con_win32.c

示例7: GetStdHandle

WindowsInputController::WindowsInputController() { 
    HANDLE hStdin; 
    DWORD fdwMode, fdwSaveOldMode; 
 
    // Get the standard input handle. 
    hStdin = GetStdHandle( STD_INPUT_HANDLE ); 
    if( hStdin == INVALID_HANDLE_VALUE ) 
        return;
 
    // Save the current input mode, to be restored on exit. 
    if( !GetConsoleMode(hStdin, &fdwSaveOldMode) ) 
        return; 
 
    // Enable the window and mouse input events. 
    fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; 
    if( !SetConsoleMode(hStdin, fdwMode) ) 
        return; 
 
}
开发者ID:TomaszSakrejda,项目名称:musiqcWashington,代码行数:19,代码来源:input.cpp

示例8: sizeof

DWORD CPequote::Start()
{	
	//CEgRegKey key;
	CModuleVersion ver;
	TCHAR pModName [1024] = { 0 };
	TCHAR pVer[100] = { 0 };
    
    //detecting the module version
	::GetModuleFileName( NULL, pModName, sizeof(pModName)/sizeof(TCHAR));
	ver.GetModuleVersionInfo(pModName);		
	ver.GetValue(_T("ProductVersion"), pVer);

	DWORD dwFlags;
	if(GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwFlags))
	{
		dwFlags &= ~(ENABLE_QUICK_EDIT | ENABLE_INSERT_MODE);
		SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), dwFlags);
	}

	m_hStopApplication = ::CreateEvent(NULL, TRUE, FALSE, NULL);
	if (!m_hStopApplication)
	{
		return TraceError();
	}
	
	if (!::SetConsoleCtrlHandler(HandlerRoutine, TRUE))
		return TraceError();

	CTracer::TraceMessage(CTracer::enMtInformation, NULL, _T("Starting Pequote connector..."));

	DWORD dwRes = m_PequoteConnector.Start(NULL);	
	if (dwRes)
	{
		CTracer::TraceMessage(CTracer::enMtError, NULL, _T("Failed to start Pequote connector."));
		return dwRes;
	}

	CTracer::TraceMessage(CTracer::enMtInformation, NULL, _T("Pequote connector started."));
	CTracer::TraceMessage(CTracer::enMtInformation, NULL, _T("Server started."));
    
	return 0;
}
开发者ID:AlexS2172,项目名称:IVRM,代码行数:42,代码来源:PequoteImpl.cpp

示例9: noecho_console

static int noecho_console(UI *ui)
{
#ifdef TTY_FLAGS
    memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig));
    tty_new.TTY_FLAGS &= ~ECHO;
#endif

#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
    if (is_a_tty && (TTY_set(fileno(tty_in), &tty_new) == -1))
        return 0;
#endif
#ifdef OPENSSL_SYS_VMS
    if (is_a_tty) {
        tty_new[0] = tty_orig[0];
        tty_new[1] = tty_orig[1] | TT$M_NOECHO;
        tty_new[2] = tty_orig[2];
        status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12,
                          0, 0, 0, 0);
        if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) {
            char tmp_num[2][12];

            BIO_snprintf(tmp_num[0], sizeof(tmp_num[0]) - 1, "%%X%08X",
                         status);
            BIO_snprintf(tmp_num[1], sizeof(tmp_num[1]) - 1, "%%X%08X",
                         iosb.iosb$w_value);
            UIerr(UI_F_NOECHO_CONSOLE, UI_R_SYSQIOW_ERROR);
            ERR_add_error_data(5, "status=", tmp_num[0],
                               ",", "iosb.iosb$w_value=", tmp_num[1]);
            return 0;
        }
    }
#endif
#if defined(_WIN32) && !defined(_WIN32_WCE)
    if (is_a_tty) {
        tty_new = tty_orig;
        tty_new &= ~ENABLE_ECHO_INPUT;
        SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), tty_new);
    }
#endif
    return 1;
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:41,代码来源:ui_openssl.c

示例10: init_terminal

/*
 * initialize the terminal data structures.
 */
void init_terminal(void) {
    if (ttyoring.init(2*BUFSIZ, ttysink, NULL) != 1) {
	exit(1);
    }
    if (ttyiring.init(BUFSIZ, NULL, ttysrc) != 1) {
	exit(1);
    }
    autoflush = TerminalAutoFlush();
#ifdef __WIN32__
    /*
     * Set the console mode.  This will only have an effect if the
     * handle is a console handle
     */
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
#if 0
    printf("1. Calling SetConsoleMode(0x%08x, 0x%08x)\n",
	   hOut, ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT);
#endif
    SetConsoleMode(hOut, ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT);
#endif
}
开发者ID:gordonchaffee,项目名称:expectnt,代码行数:24,代码来源:terminal.cpp

示例11: stdin_echo

void stdin_echo(bool enable)
{
	#ifdef WIN32
		HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);
		DWORD mode;
		GetConsoleMode(hStdin,&mode);
		if(!enable)
			mode&=~ENABLE_ECHO_INPUT;
		else
			mode|=ENABLE_ECHO_INPUT;
		SetConsoleMode(hStdin, mode );
	#else
		struct termios tty;
		tcgetattr(STDIN_FILENO,&tty);
		if(!enable)
			tty.c_lflag&=~ECHO;
		else
			tty.c_lflag|=ECHO;
		tcsetattr(STDIN_FILENO,TCSANOW,&tty);
	#endif
}
开发者ID:mrmoss,项目名称:enano,代码行数:21,代码来源:console.cpp

示例12: termset

static void
termset(void)
{
	DWORD flag;

	if(donetermset)
		return;
	donetermset = 1;
	conh = GetStdHandle(STD_OUTPUT_HANDLE);
	kbdh = GetStdHandle(STD_INPUT_HANDLE);
	errh = GetStdHandle(STD_ERROR_HANDLE);
	if(errh == INVALID_HANDLE_VALUE)
		errh = conh;

	// The following will fail if kbdh not from console (e.g. a pipe)
	// in which case we don't care
	GetConsoleMode(kbdh, &consolestate);
	flag = consolestate;
	flag = flag & ~(ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT);
	SetConsoleMode(kbdh, flag);
}
开发者ID:8l,项目名称:inferno,代码行数:21,代码来源:os.c

示例13: mygetch

/** get a character from the terminal */
int
mygetch(void)
{
#if !defined(_WIN32) || !defined(__CYGWIN__)
    /* longjmp won't work, it's in a different thread */
    sighandler_t savesig; /* old value of signal */
#endif
    int c;

    /* change an interrupt signal to a break key character */
    if (setjmp(env) == 0) {
#if defined(_WIN32) && !defined(__CYGWIN__)
	/* turn off Ctrl+C handling (PDCurses does this, but it gets turned on
	   again by CMD during system) */
	SetConsoleMode( GetStdHandle( STD_INPUT_HANDLE ), 0 );
#else
	savesig = signal(SIGINT, catchint);
#endif
	refresh();	/* update the display */
	mousereinit();	/* curses can change the menu number */
	if(prevchar) {
	    c = prevchar;
	    prevchar = 0;
	} else {
	    c = -1;
	    while (c == -1) {
		/* get a character from the terminal */
		c = getch();
		if ((c == -1) && (errno != EINTR))
		    break;
	    }
	}
    } else {	/* longjmp to here from signal handler */
	c = KEY_BREAK;
    }
#if !defined(_WIN32) || !defined(__CYGWIN__)
    signal(SIGINT, savesig);
#endif
    return(c);
}
开发者ID:libaoyuan242,项目名称:emacs_config,代码行数:41,代码来源:input.c

示例14: CON_Init

/*
==================
CON_Init
==================
*/
void CON_Init( void )
{
	CONSOLE_SCREEN_BUFFER_INFO info;
	char consoleTitle[128];
	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;
	qconsole_backgroundAttrib = qconsole_attrib & (BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_RED|BACKGROUND_INTENSITY);

	// ZTM: FIXME: com_productName isn't initialized or set to game title yet.
	Com_sprintf( consoleTitle, sizeof (consoleTitle), "%s Dedicated Server Console", com_productName ? com_productName->string : PRODUCT_NAME );
	SetConsoleTitle( consoleTitle );

	// initialize history
	for( i = 0; i < QCONSOLE_HISTORY; i++ )
		qconsole_history[ i ][ 0 ] = '\0';

	// set text color to white
	SetConsoleTextAttribute( qconsole_hout, CON_ColorCharToAttrib( COLOR_WHITE ) );
}
开发者ID:mecwerks,项目名称:spearmint,代码行数:45,代码来源:con_win32.c

示例15: readpassphrase

static char *
readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
{
	HANDLE hStdin, hStdout;
	DWORD mode, rbytes;
	BOOL success;

	(void)flags;

	hStdin = GetStdHandle(STD_INPUT_HANDLE);
	if (hStdin == INVALID_HANDLE_VALUE)
		return (NULL);
	hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	if (hStdout == INVALID_HANDLE_VALUE)
		return (NULL);

	success = GetConsoleMode(hStdin, &mode);
	if (!success)
		return (NULL);
	mode &= ~ENABLE_ECHO_INPUT;
	mode |= ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
	success = SetConsoleMode(hStdin, mode);
	if (!success)
		return (NULL);

	success = WriteFile(hStdout, prompt, (DWORD)strlen(prompt),
		NULL, NULL);
	if (!success)
		return (NULL);
	success = ReadFile(hStdin, buf, (DWORD)bufsiz - 1, &rbytes, NULL);
	if (!success)
		return (NULL);
	WriteFile(hStdout, "\r\n", 2, NULL, NULL);
	buf[rbytes] = '\0';
	/* Remove trailing carriage return(s). */
	if (rbytes > 2 && buf[rbytes - 2] == '\r' && buf[rbytes - 1] == '\n')
		buf[rbytes - 2] = '\0';

	return (buf);
}
开发者ID:KitoHo,项目名称:libarchive,代码行数:40,代码来源:passphrase.c


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