Important alert: (current site time 5/18/2013 9:42:45 AM EDT)
 

winzip icon

CAP - Build Real (!) Console Apps with VB6!

Email
Submitted on: 9/2/2002 10:51:57 AM
By: gridrun 
Level: Intermediate
User Rating: By 40 Users
Compatibility: VB 6.0
Views: 18197
 
     Finally: CAP lets you create and compile "true" console applications with VB6. "True" as in: Not those cheesy things that open up a new console window! Instead, a console app made with CAP will run in a DOS console (or a cmd.exe session). See the included demo project (a "port" of the UNIX uname command). Did I mention that the included bas module supports STDIO and debugging in the VB IDE, with a console? There is also a short .txt file elaborating some more on the topic, too. Please vote if you find this useful, thank you!

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
9/2/2002 11:18:37 AMgridrun

very simple, but great effect. Please vote if you like it :P
(If this comment was disrespectful, please report it.)

 
9/2/2002 11:37:52 AMgridrun

OK. Quick installation instructions for those who are too lazy to read the included .txt: 1) Compile CAP.EXE from the provided source 2) go to your VB folder (usually its named VB98). 3) rename LINK.EXE in the VB folder to LINK.ORIG.EXE 4) Copy CAP.exe into the VB folder 5) Rename CAP.EXE to LINK.EXE 6) Launch VB6 IDE 7) Try to compile something, CAP shuld pop up and show 3 buttons (A)bort, (C)onsole and (W)indows. For more info... read the .txt file in the ZIP, heh !
(If this comment was disrespectful, please report it.)

 
9/2/2002 11:43:04 AMCoding Genius

Great stuff. Very interesting concept. It works nocely! If I were you I'd make a batch file to do the ''Installation'' automatically ;) That should be foolproof right? I gave you 5, not 1 by the way ;)
(If this comment was disrespectful, please report it.)

 
9/2/2002 2:15:35 PMM1K3

Really nice, but I wish you would take your sunglasses off before taking a screenshot...
(If this comment was disrespectful, please report it.)

 
9/2/2002 5:34:46 PMgridrun

fixed :P
(If this comment was disrespectful, please report it.)

 
9/2/2002 7:54:27 PM

I am quite impressed. ;) Tis good to have you around #VB!
(If this comment was disrespectful, please report it.)

 
9/2/2002 8:12:44 PMbobock

sweet
(If this comment was disrespectful, please report it.)

 
9/3/2002 1:11:14 AMCeLiX

Nice! 5 from Me!
(If this comment was disrespectful, please report it.)

 
9/3/2002 7:40:19 AMjoesatri

hmmm.. yeah..
i'll give you a sqrt(25) ...
and..yes.. #vb on eu.undernet.org rules..
(If this comment was disrespectful, please report it.)

 
9/3/2002 9:04:26 AM

Nice Effort! You Get A 4
(If this comment was disrespectful, please report it.)

 
9/3/2002 5:32:33 PMRussell Kinasz

Nice Job! 5 4 U
(If this comment was disrespectful, please report it.)

 
9/3/2002 8:22:13 PM

Ill try it first
(If this comment was disrespectful, please report it.)

 
9/6/2002 3:32:16 PMgridrun

thanks for all the votes and comments. If you want, I will post a short tutorial on how to write console apps with this.
(If this comment was disrespectful, please report it.)

 
9/17/2002 6:45:29 PM

Great sample! And it works like a charm! Also, the instruction is very detailed and easy to follow, a 5 for you. Job well done!
(If this comment was disrespectful, please report it.)

 
9/27/2002 4:27:18 PM

There are free add-ins already available that do this seamlessly WITHOUT mucking with the linker executable (which could render your VB installation useless). Here are the links:
www.vbadvance.com
www.powervb.com
(If this comment was disrespectful, please report it.)

 
9/29/2002 10:29:45 AMgridrun

I've seen matt curlands addin, but I found the toggle switch quite irritating - I wanted it the way CAP does it. Besides, tampering with the CreateProcess API is at least undocumented, if not dangerous too :) Plus you dont need to buy a book for the sourcecode with CAP! I also took a look at the other addin link you posted, but i noticed "You are welcome to download a copy of vbAdvance for free evaluation. The trial version is not time-limited. If you decide to keep the software, you can purchase a single user license for only $28 US dollars." .... Well, CAP is free, nameless buddy, and doesnt cost 28 bucks for you to legally build console apps ;)
(If this comment was disrespectful, please report it.)

 
10/22/2002 9:01:53 AMKen Myers

I get an ATTRIB.EXE - Applicaiton Error. The memory could not be read when I try to compile with the new LINK.EXE. Anyone else have this problem? Otherwise, this is great.
(If this comment was disrespectful, please report it.)

 
11/1/2002 9:56:33 AM

1) The Curland add-in doesn't use CreateProcess. It uses fully documented and supported code, which you would know if you'd taken the time to look at the code.
2) vbAdvance is FREE for use in console applications, which you'd know if you'd read one sentence further than what you posted above: "(The console app creation feature is provided free of charge and is fully functional even in the trial version.)"
(If this comment was disrespectful, please report it.)

 
11/5/2002 7:38:10 PMgridrun

And if you'd have taken the time to look at this one, you'd see that it doesnt touch the original linker executable. Geez.
(If this comment was disrespectful, please report it.)

 
11/8/2002 2:27:36 PM

Huh?! From your post above: "3)
rename LINK.EXE in the VB folder to
LINK.ORIG.EXE" You're renaming the VB linker in order to disable it. I'd call that touching the linker. My point is that there are safer ways of doing this with tools that are also freely available.

(If this comment was disrespectful, please report it.)

 
11/15/2002 9:18:53 AMgridrun

You have not understood how this works. The original linker is not disabled and not touched (patched/modified) either. Please stop the dissing, thank you.
(If this comment was disrespectful, please report it.)

 
12/10/2002 9:22:33 AM

I also get the Attrib.exe error on win 2000 professional - otherwise works great. By the way can you programatically minimize the console window?
(If this comment was disrespectful, please report it.)

 
12/11/2002 6:14:48 AMgridrun

The attrib.exe thing somehow s*cks anyways, if you experience problems with it, comment the whole part out; Its only intention is to prevent VB6.exe from killing the OBJ files. Btw, to deinstall CAP, delete the CAP LINK.EXE and rename ORIG.LINK.EXE back to LINK.EXE ;)
(If this comment was disrespectful, please report it.)

 
12/12/2002 12:18:57 PM

This is great! I'm sure u got a lot of help from #vb at eu.undernet.org

(If this comment was disrespectful, please report it.)

 
12/12/2002 12:29:51 PMgridrun

dankie :) yes, #vb@undernet.org rulez ;)
(If this comment was disrespectful, please report it.)

 
12/23/2002 4:01:45 AM

Good product, despite the ATTRIB.EXE errors.
It would be nice however that when you close the Console during development, the VB.EXE does not crash...
Besides that...a great job!!!
(If this comment was disrespectful, please report it.)

 
2/17/2003 4:14:26 AMDeepak Kumar Shaw

Excellent ... but its not real console..
5 from me. Good work!!
(If this comment was disrespectful, please report it.)

 
3/4/2003 9:10:52 PM

I am using the utility to create console app under NT4. When I tried to redirect the output to a file (using ConAPI), I got the file with 0 bytes in size.
I found a simple solution to the problem:
In the ConRelease routine I added at the very fist line the following:
If IOMethod = 1 Then ' ConAPI
SetEndOfFile hConsoleOut
End
And in the Declaration section section of the module added the following line:
Private Declare Function SetEndOfFile Lib
(If this comment was disrespectful, please report it.)

 
3/4/2003 9:12:38 PM

The last one seems to have been amputated.

It should be :
Private Declare Function SetEndOfFile Lib "kernel32" (ByVal hFile As Long) As Long
(If this comment was disrespectful, please report it.)

 
4/4/2003 3:28:50 AM

I cried it was so easy to use. Got a little lost applying it but then i saw the sample code. Beautiful. Thank you.
(If this comment was disrespectful, please report it.)

 
6/16/2003 4:17:01 PM

Beautiful! Elegant and easy to implement! Thank you!
(If this comment was disrespectful, please report it.)

 
7/4/2003 7:51:33 AMThushan Fernando

hey

i know its nearly a year old but you deserve it! 5 globes!
(If this comment was disrespectful, please report it.)

 
7/5/2003 2:52:06 PMgridrun

thanks for all your comments and suggestions (especially the one with SetEndOfFile, your name unfortunately was omitted by psc)!
Deepak Kumar Shaw: Care to explain how its not real console???

(If this comment was disrespectful, please report it.)

 
7/12/2003 1:54:26 PMgridrun

If you are looking for something to facilitate processing of command line arguments in your application, then check out the 'Command Line Arguments Processor' by Daniel Keep:

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=36623&lngWId=1
< BR>I
can only recommend it
(If this comment was disrespectful, please report it.)

 
10/6/2003 3:40:05 AMAgret

This is a lie. It does not make make real console apps =/
(If this comment was disrespectful, please report it.)

 
11/18/2003 3:19:58 PMAriesM

Thanks for the effort on building this utility. However, I do have one major concern, and perhaps you may have found a solution for my concern. My concern is when I used your program, somehow many of my .exe files have been corrupted (ie something like cannot read memory or they simply won't open), as such I had to rebuild my machine. Can you help me understand why? Thanks again gridrun!

CyberDude
(If this comment was disrespectful, please report it.)

 
11/26/2003 2:18:26 PM

generally speaking, its a nice project. you've got some major white space issues in your code but overall pretty sweet.
(If this comment was disrespectful, please report it.)

 
1/29/2004 2:41:10 PM

Nice work gridrun! This has been extremely help for implementing a project where the APIs were not .NET ready.
(If this comment was disrespectful, please report it.)

 
12/13/2004 1:41:24 AM

Hey !! Fantastic code !! Love it ... but anyway to return error codes ?? You simply cannot use conprint to return error codes right ? Take it for example in C programming that you can return error codes using the return function at the end of the function.

(If this comment was disrespectful, please report it.)

 
2/27/2005 7:01:42 AMHardStream Software Development

OK, this is REALLY COOL!!!
I always used .NET to write console applications, but now I can **FINALY** write console applications.
5x*
(If this comment was disrespectful, please report it.)

 
1/29/2006 5:34:36 PMd.velo.de

Great code, fantastic!
(If this comment was disrespectful, please report it.)

 
1/29/2010 9:01:55 PMSting-Ray

I STILL use this app. in my projects to this day. Long live Classic Visual Basic (VB6)!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.