Re: console output

From: peter walker (peter_at_papwalker.com.au.nospam)
Date: 04/26/04


Date: Tue, 27 Apr 2004 00:13:47 +1000

yes I realise what you say is true..however it's not relevant to what I'm
asking. I understand about services as I write my own using Delphi (not C++)
I can't offer him any worthwhile advise..

I am talking about writing to the console during the installation I know
some services that use
servicename /i

or

servicename / u

to install and uninstall the service from the SCM registry.
The generally write to the console ala...

servicename uninstalled successfully

or
...the service installed successfully - do you want to start it?
do you follow me?

-- 
peter walker MVP
Please post replies to the news group so everyone can benefit.
www.papwalker.com
"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:u6NF1dvKEHA.3500@TK2MSFTNGP12.phx.gbl...
> "peter walker" <peter@papwalker.com.au.nospam> wrote in message
> news:%23i415hqKEHA.2556@TK2MSFTNGP11.phx.gbl...
> > A friend of mine is working on a service application for me.
> > He is trying to write to the console during the command line
installation
> > and registration of the service but the printf does not produce output.
> > (neither does the writefile stdio. Also interestingly changing the
winmain
> > to main results in duplicate declaration of new and dispose.
> >
> > any ideas?
>
> Services by default run on an invisible desktop and not the interactive
> desktop with which you are familiar.
>
> Many service shell's provide a facility for running a service as a console
> application on the interactive desktop. That's good as far as it goes but
> ultimately you will want to debug the service where it sits.
>
> If your friend passes a null terminated string containing the name of a
log
> file to this function:
>
> /*************************************************************************
>  Sets the standard output device to point to the passed file name
> *************************************************************************/
> void CreateTraceLogFile(LPSTR pszName)
> {
>  int    fd;
>  FILE   *fp;
>  HANDLE hFile;
>
>  hFile = CreateFile(pszName, GENERIC_WRITE, FILE_SHARE_READ, NULL,
>                     OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
>
>  if ( hFile != INVALID_HANDLE_VALUE )
>  {
>   SetFilePointer(hFile, 0, NULL, FILE_END);
>
>   fd = _open_osfhandle( (long)hFile, 0);
>   fp = _fdopen(fd, "w");
>
>   *stdout = *fp;
>   setvbuf(stdout, NULL, _IONBF, 0);
>  }
> }
>
> then all of what would otherwise been displayed in a console window will
be
> written to a file without his having to change his code. What I do in my
> services is to put the name of the trace log in the config file or
registry
> settings. If such a setting is present (as when I am debugging) I call the
> function above.
>
> The way I have written it, the trace log is cumulative. If you want to
start
> fresh each time change "FILE_END" to "FILE_BEGIN" above.
>
> Regards,
> Will
>
>


Relevant Pages

  • Re: Cannot log in to a user
    ... I'm just not sure about the recovery ... Is this the same console? ... >correct the registry damage. ... >the registry hive from another installation and change ...
    (microsoft.public.windowsxp.basics)
  • Re: The Beginning Of The End For Micro$oft Reign Of Terror
    ... Linux config files can contain comments and are very ... cryptic variable names and values like those frequently found in the registry. ... # serial port in addition to or instead of the keyboard/video console. ...
    (comp.security.firewalls)
  • (no subject)
    ... Linux config files can contain comments and are very ... cryptic variable names and values like those frequently found in the registry. ... # serial port in addition to or instead of the keyboard/video console. ...
    (comp.security.firewalls)
  • Re: Not able to Login to F10
    ... Before you can type these command's you need the console before it crashes ... Installation went fine but when booted, ... Till yesterday my F9 works like charm with full yum updates. ... If you can, install updates and reboot. ...
    (Fedora)
  • Re: [SUMMARY] Problems with XVR-4000 graphics board and V880z, and Xservers config
    ... Sun engineer is looking into whether this is possible, ... > XVR-100 is console framebuffer. ... > The man pages and installation docs are terrible. ...
    (SunManagers)