Re: console output
From: peter walker (peter_at_papwalker.com.au.nospam)
Date: 04/26/04
- Next message: Ririko Horvath: "Destroying private/public keys"
- Previous message: robin: "how can i get the mainboar ID and harddisk ID"
- In reply to: William DePalo [MVP VC++]: "Re: console output"
- Next in thread: William DePalo [MVP VC++]: "Re: console output"
- Reply: William DePalo [MVP VC++]: "Re: console output"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: Ririko Horvath: "Destroying private/public keys"
- Previous message: robin: "how can i get the mainboar ID and harddisk ID"
- In reply to: William DePalo [MVP VC++]: "Re: console output"
- Next in thread: William DePalo [MVP VC++]: "Re: console output"
- Reply: William DePalo [MVP VC++]: "Re: console output"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|