By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Question about screen buffer handles

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 ...
start /b /w /k echo %%@consoleb[0]
... then just EXIT the started instance.

Similar threads