Question about screen buffer handles

May 20, 2008
12,334
134
Syracuse, NY, USA
Typically, when TCC starts, @CONSOLEB[-1] is 19. Where does that number come from? I couldn't get it in a plugin ... tried GetStdHandle and opening "CONOUT$" ... for now, settled on expanding "%@CONSOLEB[-1]".
 
It's the current console output handle. It comes from CreateFile( _TEXT("CONOUT$"), (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), &sa, OPEN_EXISTING, 0, NULL );

And you should never try to access it directly.
I tried that but with a NULL security descriptor. I suppose that's why I wasn't getting 19. I wouldn't use it, except inside @CONSOLEB. I found out (the hard way) that if TCC starts a program in the same console and that program switches to an alternative buffer and exits without switching back to its startup buffer, the parent TCC is in never_never_land. Try it ...
Code:
start /b /w /k echo %%@consoleb[0]
... then just EXIT the started instance.
 

Similar threads