<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>RE: OT: Any c++ win32 or mfc programmers here? (speech control jukebox app.)</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>jeffslists wrote:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Right now I have a simple speech application which compiles as a </FONT>
<BR><FONT SIZE=2>&gt; dialog-based application.&nbsp; I have no idea how to send output to the </FONT>
<BR><FONT SIZE=2>&gt; console from a dialog-based app.&nbsp; For now I've resorted to sending </FONT>
<BR><FONT SIZE=2>&gt; output to an edit box.&nbsp; (Sending output to the edit box was much more </FONT>
<BR><FONT SIZE=2>&gt; complicated than I expected.&nbsp; I spent two hours trying to figure out </FONT>
<BR><FONT SIZE=2>&gt; just how to automatically scroll the damn thing.)</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; I would rather send trace output to the console/stdout than use an </FONT>
<BR><FONT SIZE=2>&gt; edit box.&nbsp; I could create a new project in MS VC 6.0 as a console </FONT>
<BR><FONT SIZE=2>&gt; based application, which would give me easy access to the console, but I do</FONT>
<BR><FONT SIZE=2>&gt; not know windows programming well enough to restructure the speech app&nbsp;&nbsp; .</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Here is a link to the app. I am working with:</FONT>
<BR><FONT SIZE=2>&gt; *SAPI 5.0 Tutorial I: An Introduction to SAPI* </FONT>
<BR><FONT SIZE=2>&gt; &lt;<A HREF="http://www.generation5.org/content/2001/sr00.asp" TARGET="_blank">http://www.generation5.org/content/2001/sr00.asp</A>&gt;</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Is there anyone here who can give me hand? </FONT>
</P>

<P><FONT SIZE=2>Gerald's reply reminded me that I'd faced the same issue using Rational Visual Test. There were 2 ways I found to get access to a console from a dialog based app. You can create a named pipe wrapper. See the following article: <A HREF="http://www.codeguru.com/console/dualmode.html" TARGET="_blank">http://www.codeguru.com/console/dualmode.html</A></FONT></P>

<P><FONT SIZE=2>Or you could go down the AllocConsole route as Gerald mentioned. Here's a cut of proof of concept code I used in Visual Test Basic which illustrates that route:</FONT></P>

<P><FONT SIZE=2>'winbase.h</FONT>
<BR><FONT SIZE=2>macro STD_INPUT_HANDLE&nbsp; = -10</FONT>
<BR><FONT SIZE=2>macro STD_OUTPUT_HANDLE = -11</FONT>
<BR><FONT SIZE=2>macro STD_ERROR_HANDLE&nbsp; = -12</FONT>
<BR><FONT SIZE=2>macro FILE_TYPE_UNKNOWN = &amp;h0000</FONT>
<BR><FONT SIZE=2>macro FILE_TYPE_DISK&nbsp;&nbsp;&nbsp; = &amp;h0001</FONT>
<BR><FONT SIZE=2>macro FILE_TYPE_CHAR&nbsp;&nbsp;&nbsp; = &amp;h0002</FONT>
<BR><FONT SIZE=2>macro FILE_TYPE_PIPE&nbsp;&nbsp;&nbsp; = &amp;h0003</FONT>
<BR><FONT SIZE=2>macro FILE_TYPE_REMOTE&nbsp; = &amp;h8000</FONT>
</P>

<P><FONT SIZE=2>declare function AllocConsole% lib &quot;kernel32.dll&quot; ()</FONT>
<BR><FONT SIZE=2>declare function FreeConsole% lib &quot;kernel32.dll&quot; ()</FONT>
<BR><FONT SIZE=2>declare function GetStdHandle&amp; lib &quot;kernel32.dll&quot; (hStd&amp;) ' STD_?_HANDLE, ? = INPUT, OUTPUT, or ERROR</FONT>
<BR><FONT SIZE=2>declare function GetFileType&amp; lib &quot;kernel32.dll&quot; (osfHandle&amp;)</FONT>
<BR><FONT SIZE=2>declare function WriteFile&amp; lib &quot;kernel32.dll&quot; (hFile&amp;, szWriteBuffer$, sizeWriteBuffer&amp;, ytesWritten as pointer to long, overlap as pointer to long)</FONT></P>
<BR>

<P><FONT SIZE=2>declare function CreateProcess&amp; lib &quot;kernel32.dll&quot; alias &quot;CreateProcessA&quot; (lpApplicationName$, lpCommandLine$, lpProcessAttributes as SECURITY_ATTRIBUTES, lpThreadAttributes as SECURITY_ATTRIBUTES, bInheritHandles&amp;, dwCreationFlags&amp;, lpEnvironment as any, lpCurrentDirectory$, lpStartupInfo as STARTUPINFOA, lpProcessInformation as PROCESS_INFORMATION)</FONT></P>

<P><FONT SIZE=2>declare function CloseHandle lib &quot;kernel32.dll&quot; (hObject as long) as long</FONT>
</P>

<P><FONT SIZE=2>macro CRLF = chr(10) + chr(13)</FONT>
<BR><FONT SIZE=2>macro NORMAL_PRIORITY_CLASS = &amp;H00000020</FONT>
</P>

<P><FONT SIZE=2>type PROCESS_INFORMATION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' The PROCESS_INFO structure is used by</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; hProcess&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long ' the CreateProcessA function to return</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; hThread&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long ' information about the newly created process</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwProcessId&nbsp;&nbsp;&nbsp;&nbsp; as long&nbsp; ' The two handles that are returned in this</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwThreadId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long&nbsp; ' structure are open handles to the new</FONT>
<BR><FONT SIZE=2>end type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' process and its primary thread</FONT>
</P>

<P><FONT SIZE=2>type STARTUPINFOA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' The STARTUPINFOA structure allows</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; cb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long&nbsp; ' the CreateProcessA function to control</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; lpReserved&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long ' many aspects of the creation process</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; lpDesktop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; lpTitle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwXSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwYSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwXCountChars&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwYCountChars&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwFillAttribute as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; dwFlags&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; wShowWindow&nbsp;&nbsp;&nbsp;&nbsp; as short</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; cbReserved2&nbsp;&nbsp;&nbsp;&nbsp; as short</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; lpReserved2&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; hStdInput&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; hStdOutput&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; hStdError&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as long</FONT>
<BR><FONT SIZE=2>end type</FONT>
</P>

<P><FONT SIZE=2>dim osfSTDOUT&amp;, text$, pi as PROCESS_INFORMATION, si as STARTUPINFOA</FONT>
<BR><FONT SIZE=2>const STATEMENT$ = &quot;How am I doing?&quot; + chr(10) + chr(13)</FONT>
</P>

<P><FONT SIZE=2>AllocConsole</FONT>
<BR><FONT SIZE=2>osfSTDOUT = GetStdHandle(STD_OUTPUT_HANDLE)</FONT>
<BR><FONT SIZE=2>if FILE_TYPE_CHAR = GetFileType(osfSTDOUT) then</FONT>
<BR><FONT SIZE=2>&nbsp; WriteFile(osfSTDOUT, STATEMENT, len(STATEMENT), Null, Null)</FONT>
<BR><FONT SIZE=2>&nbsp; sleep 3</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>CreateProcess(null, &quot;c:\winnt\system32\cmd.exe&quot;, null, null, FALSE, _</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NORMAL_PRIORITY_CLASS, 0, &quot;C:\.&quot;, si, pi)</FONT>
<BR><FONT SIZE=2>&nbsp; sleep 10</FONT>
<BR><FONT SIZE=2>endif</FONT>
<BR><FONT SIZE=2>CloseHandle(pi.hProcess)</FONT>
<BR><FONT SIZE=2>CloseHandle(pi.hThread)</FONT>
<BR><FONT SIZE=2>FreeConsole</FONT>
</P>

<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>Garrett Goebel</FONT>
<BR><FONT SIZE=2>IS Development Specialist</FONT>
</P>

<P><FONT SIZE=2>ScriptPro&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Direct: 913.403.5261</FONT>
<BR><FONT SIZE=2>5828 Reeds Road&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main: 913.384.1008</FONT>
<BR><FONT SIZE=2>Mission, KS 66202&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax: 913.384.2180</FONT>
<BR><FONT SIZE=2>www.scriptpro.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; garrett at scriptpro dot com</FONT>
</P>
<BR>

</BODY>
</HTML>