<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to  create a VB6 console program</title>
	<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/</link>
	<description>Stay curious!</description>
	<pubDate>Sun, 20 Jul 2008 11:22:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Jorgen</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14852</link>
		<author>Jorgen</author>
		<pubDate>Thu, 03 Jul 2008 22:28:16 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14852</guid>
		<description>I worked for a company in 1999 where I had to make some commandtools. We were using VB6 as the only developer env. - none of us was C/C   sharks. We droped the commandline tool idea, but since then, I haved searched the net for exactly what your example does. Many have written that it is not possible to create a commandline tool in vb - it is a VISUAL tool ;-). But I have never gived up. Tonight my eyes get wet... :-). Great Work. 
Just one comment: I just placed a vbcrlf in the WriteStdOut in your code.</description>
		<content:encoded><![CDATA[<p>I worked for a company in 1999 where I had to make some commandtools. We were using VB6 as the only developer env. - none of us was C/C   sharks. We droped the commandline tool idea, but since then, I haved searched the net for exactly what your example does. Many have written that it is not possible to create a commandline tool in vb - it is a VISUAL tool ;-). But I have never gived up. Tonight my eyes get wet&#8230; :-). Great Work.<br />
Just one comment: I just placed a vbcrlf in the WriteStdOut in your code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avery</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14675</link>
		<author>avery</author>
		<pubDate>Thu, 29 May 2008 23:37:47 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14675</guid>
		<description>Just wondering how might i do the opposite
make a regular vb6 program read and write to a win32 (not neccesarily vb6) win32 console ? (ie stdin stdout)</description>
		<content:encoded><![CDATA[<p>Just wondering how might i do the opposite<br />
make a regular vb6 program read and write to a win32 (not neccesarily vb6) win32 console ? (ie stdin stdout)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avery</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14674</link>
		<author>avery</author>
		<pubDate>Thu, 29 May 2008 23:19:55 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14674</guid>
		<description>ok i did everything that it said in this article and it works apparently,

except 2 bugs,

it writes out to the same first line and writes over itself,
i guess this is not a problem cause the gui interprets every line anyway(??)

2. my program is behaving differently when it is run than when i debug it. (i have just been observing the watch values and not allowing stdout write stdout)

is a UCI chess program

--&#62; from gui
 uci
 uci (me typing)
</description>
		<content:encoded><![CDATA[<p>ok i did everything that it said in this article and it works apparently,</p>
<p>except 2 bugs,</p>
<p>it writes out to the same first line and writes over itself,<br />
i guess this is not a problem cause the gui interprets every line anyway(??)</p>
<p>2. my program is behaving differently when it is run than when i debug it. (i have just been observing the watch values and not allowing stdout write stdout)</p>
<p>is a UCI chess program</p>
<p>&#8211;&gt; from gui<br />
 uci<br />
 uci (me typing)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Bowen</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14214</link>
		<author>David Bowen</author>
		<pubDate>Thu, 14 Feb 2008 11:30:29 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-14214</guid>
		<description>Fab - great job.</description>
		<content:encoded><![CDATA[<p>Fab - great job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: B0B</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-13453</link>
		<author>B0B</author>
		<pubDate>Thu, 04 Oct 2007 20:18:31 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-13453</guid>
		<description>Cool ;)</description>
		<content:encoded><![CDATA[<p>Cool ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-6441</link>
		<author>Adam</author>
		<pubDate>Wed, 09 May 2007 12:58:12 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-6441</guid>
		<description>&lt;p&gt;Hi
i am tearing my hair of because i don't know how to get the return value after that i have executed an exe file from within an VB application. The language used is VB6 

The code that is already written looks as follow:&lt;/p&gt;

&lt;pre&gt;ShellId = Shell("C:\WINDOWS\system32\cmd.exe /c " &#38; command &#38; " &#62; " &#38; fileName, vbHide)
ShellHandle = OpenProcess(SYNCHRONIZE, 0, ShellId)&lt;/pre&gt;

&lt;p&gt;I wonder how to get the returned value from the executed file if it's possible to do so. In this example it is netdom.exe that i hope to catch the return value from.

Many thanks..
Adam&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hi<br />
i am tearing my hair of because i don&#8217;t know how to get the return value after that i have executed an exe file from within an VB application. The language used is VB6 </p>
<p>The code that is already written looks as follow:</p>
<pre>ShellId = Shell("C:WINDOWSsystem32cmd.exe /c " &amp; command &amp; " &gt; " &amp; fileName, vbHide)
ShellHandle = OpenProcess(SYNCHRONIZE, 0, ShellId)</pre>
<p>I wonder how to get the returned value from the executed file if it&#8217;s possible to do so. In this example it is netdom.exe that i hope to catch the return value from.</p>
<p>Many thanks..<br />
Adam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-6437</link>
		<author>Tony</author>
		<pubDate>Wed, 09 May 2007 05:54:45 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-6437</guid>
		<description>&lt;p&gt;Using the Shell function to execute another console application will not create another console, if the current VB application already owns one (as in this case). So principially this will work well. The only caveat is that the Shell function runs the application in paralell to current process. All we need is to wait until the child process terminates. A few API calls will do it. An example follows (note the differences when run as a normal VB application and when run as a console app):Wow, an on-point article that is easy to read with a quick answer to the question I’ve got. That, and the suggestions really work, too! Kudos!&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Using the Shell function to execute another console application will not create another console, if the current VB application already owns one (as in this case). So principially this will work well. The only caveat is that the Shell function runs the application in paralell to current process. All we need is to wait until the child process terminates. A few API calls will do it. An example follows (note the differences when run as a normal VB application and when run as a console app):Wow, an on-point article that is easy to read with a quick answer to the question I’ve got. That, and the suggestions really work, too! Kudos!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timo</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-6066</link>
		<author>Timo</author>
		<pubDate>Thu, 26 Apr 2007 23:36:22 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-6066</guid>
		<description>&lt;p&gt;Excellent article. I keep coming back to this link over the years each time I need to do this. Thankyou.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Excellent article. I keep coming back to this link over the years each time I need to do this. Thankyou.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl E. Peterson</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-1992</link>
		<author>Karl E. Peterson</author>
		<pubDate>Tue, 26 Sep 2006 20:07:56 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-1992</guid>
		<description>&lt;p&gt;Well, yeah, that’s the general outline, alright. For all the code, ready to roll right into your applications, see my &lt;a href="http://vb.mvps.org/samples/Console"&gt;Console application sample&lt;/a&gt; and &lt;a href="http://vb.mvps.org/samples/CmdLine"&gt;Command Line processing sample&lt;/a&gt;. On the first page, there are links to several free addins that eliminate the awkward Link step above, as well. One aspect of the Console sample that folks really appreciate is that it fully supports debugging within the VB IDE.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Well, yeah, that’s the general outline, alright. For all the code, ready to roll right into your applications, see my <a href="http://vb.mvps.org/samples/Console">Console application sample</a> and <a href="http://vb.mvps.org/samples/CmdLine">Command Line processing sample</a>. On the first page, there are links to several free addins that eliminate the awkward Link step above, as well. One aspect of the Console sample that folks really appreciate is that it fully supports debugging within the VB IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-1819</link>
		<author>Martin</author>
		<pubDate>Fri, 15 Sep 2006 11:50:22 +0000</pubDate>
		<guid>http://www.xaprb.com/blog/2005/10/14/how-to-create-a-vb6-console-program/#comment-1819</guid>
		<description>&lt;p&gt;A small update to my previous post:&lt;/p&gt;

&lt;p&gt;Using the Shell function to execute another console application will not create another console, if the current VB application already owns one (as in this case). So principially this will work well. The only caveat is that the Shell function runs the application in paralell to current process. All we need is to wait until the child process terminates. A few API calls will do it. An example follows (note the differences when run as a normal VB application and when run as a console app):&lt;/p&gt;

&lt;pre&gt;Option Explicit

Const PROCESS_QUERY_INFORMATION = &#38;H400&#38;
Const SYNCHRONIZE = &#38;H100000
Const INFINITE = -1&#38;

Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Sub ShellWait(PathName As String, WindowStyle As VbAppWinStyle)
    Dim ID As Long, Proc As Long
    
    ID = Shell(PathName, WindowStyle)
    Proc = OpenProcess(SYNCHRONIZE + PROCESS_QUERY_INFORMATION, 0, ID)
    WaitForSingleObject Proc, INFINITE
    CloseHandle Proc
End Sub

Sub Main()
    ShellWait "CMD.EXE /C dir C:\", vbMinimizedFocus
    ShellWait "CMD.EXE /C pause", vbMinimizedFocus
End Sub&lt;/pre&gt;

&lt;p&gt;I'd also like to thank the author of the original article. It was extremely helpful to me. I was basically aware of all the needed API functions. The only elusive thing was the relink trick.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>A small update to my previous post:</p>
<p>Using the Shell function to execute another console application will not create another console, if the current VB application already owns one (as in this case). So principially this will work well. The only caveat is that the Shell function runs the application in paralell to current process. All we need is to wait until the child process terminates. A few API calls will do it. An example follows (note the differences when run as a normal VB application and when run as a console app):</p>
<pre>Option Explicit

Const PROCESS_QUERY_INFORMATION = &amp;H400&amp;
Const SYNCHRONIZE = &amp;H100000
Const INFINITE = -1&amp;

Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Sub ShellWait(PathName As String, WindowStyle As VbAppWinStyle)
    Dim ID As Long, Proc As Long

    ID = Shell(PathName, WindowStyle)
    Proc = OpenProcess(SYNCHRONIZE + PROCESS_QUERY_INFORMATION, 0, ID)
    WaitForSingleObject Proc, INFINITE
    CloseHandle Proc
End Sub

Sub Main()
    ShellWait "CMD.EXE /C dir C:\", vbMinimizedFocus
    ShellWait "CMD.EXE /C pause", vbMinimizedFocus
End Sub</pre>
<p>I&#8217;d also like to thank the author of the original article. It was extremely helpful to me. I was basically aware of all the needed API functions. The only elusive thing was the relink trick.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
