Quote Originally Posted by dilettante View Post
I didn't think you needed to, but it may make sense to call CloseHandle() on the StdIO handles on exit.
Somebody in the Community Additions section of the GetStdHandle function's documentation thinks it may not be necessary:

Quote Originally Posted by BlueViper02
Typically, do not close the returned handle

It is not a duplicate handle, it is the real thing, so think twice before closing it


BTW, The trick has shared an undocumented .VBP section tip that enables a Standard EXE project to be compiled as a console application (or standard DLL) without requiring post-processing of the EXE or use of IDE add-ins that hook into the build process:

Code:
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\Windows\system32\stdole2.tlb#OLE Automation
Module=Module1; Module1.bas
Startup="Sub Main"
ExeName32="ConEater.exe"
Command32=""
Name="ConEater"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="BVO Computing Services"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1

[VBCompiler]
LinkSwitches=/SUBSYSTEM:CONSOLE