PowerVB.com Home

Console Application Add-In


The 'PowerVB Console Application Add-In' provides an integrated mechanism for turning a Standard Exe application into a console application. Using this add-in to generate a Windows Console application is equivalent to running 'EditBin /SUBSYSTEM:CONSOLE MyExe.Exe' from the command line. I'm offering this add-in license free. This add-in and source code will be included with the book sources in the next set of CD Updates.

To install the add-in:
1) Expand ConsoleApp.zip
2) Extract ConsoleApp.dll and register it with RegSvr32 (put in the PowerVB\Tools directory if you have the book installed).
3) Load the 'PowerVB Console Application Add-In' with the VB6 add-in manager (also check 'Load on Startup' if you like).
4) Now click the new menu item on the add-in menu. It toggles between 'Compile As Windows Console Application' and 'Compile As Windows GUI Application'. You get the opposite of what the menu says.
5) Make Exe or a command line build will now generate a console application.

I've added two support files and a sample to make writing to the console very easy. The first file, VBGraphics.tlb, provides an interface that allows you to use the VB Print functionality against any object. The second file, StdOutput.cls, uses this interface to write to the console. The sample project is marked as a console app with the add-in and contains the following code:

Option Explicit
Public stdout As StdOutput
Sub Main()
    Set stdout = New StdOutput
    stdout.Print "Sample Console output"
End Sub