8
votes

I did some googling to try to answer this question but even after that I'm not quite clear about something. Is it possible to create a console app from VB6?

I've got a VB6 app that doesn't put up a window. I always assumed that it was a console app. However, I want to be able to use the Windows API SetConsoleCtrlHandler function from within it. I believe that with C++/MFC apps you have to set a linker switch to create a console app. And one of my fellow developers told me that VB6 doesn't create a true console app and therefore this would not work. So is it possible to create a console app that Windows will recognize as a console app from VB6?

Platform: Windows XP SP2

Development Platform: VB6

3

3 Answers

9
votes

Yes. It's also possible to create totally headless applications (which I've done a few times in the past). This link gives an example with a code snippet.

3
votes

You can use Karl E. Peterson's code at http://vb.mvps.org/samples/Console/ to create a very full-featured console application.

Simpler ones can be made by relinking the compiled VB6 EXE for the console subsystem. Karl goes into this at that same Web page. Scroll down for LinkConsole.vbs there.

0
votes

See this article.

Or you could rewrite the VB6 app as a VBScript program.