Re: Write to stdout

From: Erich Neuwirth (erich.neuwirth_at_univie.ac.at)
Date: 07/23/04


Date: Fri, 23 Jul 2004 12:24:41 +0200
To: Steve Garman <news@garman.demon.co.uk>

I tried this code for a command line app, and it did not work.
I did not crash, itjust did not write antthing visibly.
What am i doing wrong?
I was using VB6.

I want to write an exe which when called in a cmd window without
command line parameters writes a short information message in the
cmd window it is runnning in.

Steve Garman wrote:

> Steve Garman wrote:
>
>> Has anyone ever come up with an answer to the old question of how to
>> create a console app in VB that writes to stdout?
>>
>> I'm currently testing a CGI interface and need to write lots of quick
>> & dirty test programs. This is just the sort of thing that I usually
>> find VB ideal for.
>>
>> Instead, I find myself using C, C++ and VB.Net, all of which handle
>> the output perfectly well, but require me to think a bit more about
>> how to produce the data.
>>
>> I can't use CGIspawn because it's not compatible with the web-server
>> I'm using and it's really not worth the time to hack a version that
>> does work.
>>
>> Any suggestions gratefully received.
>>
>
> Thanks to all who replied.
>
> After looking at all the suggestions, I tried to use a combination of a
> batch file to do the linking and a module to wrap the API functions.
>
> The module worked ok but I couldn't get the VB5 linker to play ball.
>
> I tried with the VC98 linker (I have VC++ 6 but not VB6) Perhaps not
> surprisingly, that didn't work either.
>
> In the end, I downloaded vbAdvance though I feel a little guilty about
> that as I very much doubt I will register it. By the end of 30 days, I
> probably won't need it any more.
>
> The code I'm using for output to stdout is also mostly nicked from the
> vbAdvance site.
>
> Option Explicit
>
> Private Declare Function GetStdOutHandle Lib "kernel32" _
> Alias "GetStdHandle" _
> (Optional ByVal HandleType As Long = -11) As Long
>
> Private Declare Function WriteFile Lib "kernel32" _
> (ByVal hFile As Long, _
> ByVal lpBuffer As String, _
> ByVal cToWrite As Long, _
> ByRef cWritten As Long, _
> Optional ByVal lpOverlapped As Long) As Long
>
> Public Function ConsoleWrite(sText As String) As Long
> ConsoleWrite = WriteFile(GetStdOutHandle, _
> ByVal sText, Len(sText), ConsoleWrite)
> End Function
>
> Public Function ConsoleWriteLine(sText As String) As Long
> ConsoleWriteLine = _
> ConsoleWrite(sText & vbNewLine)
> End Function
>
> Once again, thanks for the advice. It will be much easier (for me) than
> messing about with .NOT
>



Relevant Pages

  • Re: Function call
    ... Click event line on a command button's property sheet, all I need to do is ... Public Function CloseForm(frmName as string) ... Public Function DeptForm() ... Dim strForm As String ...
    (microsoft.public.access.formscoding)
  • SoapHttpClientProtocol request canceled
    ... I have a working client-side Vb.Net app that talks to a Webspere ... inputHeaderer, String messageControlPayload, string inputMessage) ... Imports System.ComponentModel ... Public Function process3ParmRequest(ByVal inputHeader As String, ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Send a message to a Single Instance Application
    ... /// there was only one instance of the app and the command line ... /// back to the previous instance of the app. ... private static extern int SendMessage(IntPtr hWnd, int wMsg, ... private static string GetFileNameFromFullName ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Send a message to a Single Instance Application
    ... /// there was only one instance of the app and the command line ... /// back to the previous instance of the app. ... private static extern int SendMessage(IntPtr hWnd, int wMsg, ... private static string GetFileNameFromFullName ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CeRunAppAtEvent problem
    ... Your app is already running, so it is brought to the ... The API documentation states: ... The command line, ... can be one of the following string constants. ...
    (microsoft.public.dotnet.framework.compactframework)

Loading