News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

VB and consoles

Started by jj2007, October 12, 2011, 02:46:30 PM

Previous topic - Next topic

jj2007

I have these harmless two lines in Excel 2003 macro:
        Result = WinExec("D:\Masm32\ConsApp.bat " + F$, SW_SHOWNORMAL)
        MsgBox Str$(Result), vbOKOnly, "Launch result:"


The app launches, result is 33 aka "OK", but no console window. Same for a Masm console app - no console window but a MsgBox appears. Any clue why VB suppresses the console window, and how to overcome that behaviour?

Tedd

The std handles are probably redirected, so they don't show messy debug info to confused users.
Rather than linking as a console app, try explicitly creating a console window and sending your output to that.
No snowflake in an avalanche feels responsible.

jj2007

Quote from: Tedd on October 12, 2011, 10:49:01 PM
The std handles are probably redirected, so they don't show messy debug info to confused users.
Rather than linking as a console app, try explicitly creating a console window and sending your output to that.

Makes sense. Thanks, Tedd, I'll try that :thumbu

jj2007

Tedd,
Thanks again for the hint. It turns out that CreateProcess is the way to go - example and VB source are attached.

Sub TestTheLaunch()
        Launch "Greetings.exe " + Chr$(34) + "JJ was here" + Chr$(34)
End Sub


Output in console: Greetings from Excel: [JJ was here]

Source of Greetings.exe:
include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   Inkey "Greetings from Excel: [", CL$(), "]"

   Exit
end start