FreeBASIC  0.91.0
io_gethnd.c
Go to the documentation of this file.
1 /* console handle getter */
2 
3 #include "../fb.h"
4 #include "fb_private_console.h"
5 
6 static int is_init = FALSE;
7 
8 HANDLE fb_hConsoleGetHandle( int is_input )
9 {
10  if( is_init == FALSE )
11  {
12  is_init = TRUE;
13 
14  __fb_con.inHandle = GetStdHandle( STD_INPUT_HANDLE );
15  __fb_con.outHandle = GetStdHandle( STD_OUTPUT_HANDLE );
16 
17  if( __fb_con.inHandle != NULL )
18  {
19  /* Initialize console mode to enable processed input */
20  DWORD dwMode;
21  if( GetConsoleMode( __fb_con.inHandle, &dwMode ) )
22  {
23  dwMode |= ENABLE_PROCESSED_INPUT;
24  SetConsoleMode( __fb_con.inHandle, dwMode );
25  }
26  }
27 
30  }
31 
32  return (is_input? __fb_con.inHandle : __fb_con.pgHandleTb[__fb_con.active]);
33 }
34 
36 {
37  /*
38  Called by fb_FileResetEx() to cause fb_hConsoleGetHandle()
39  to reset the stored I/O handles
40  */
41  is_init = FALSE;
42 }