[fpc-pascal] Invalid standard handles in Windows service mode?
Michael Van Canneyt
michael at freepascal.org
Sat Feb 22 14:08:32 CET 2014
On Sat, 22 Feb 2014, MegaBrutal wrote:
> 2014-02-21 10:18 GMT+01:00 Michael Van Canneyt <michael at freepascal.org>:
> You can check the handle of the StdOutputHandle variable. if it is invalid (-1), you don't have output.
>
>
>
> Thanks for your reply, it helped a lot! StdOutputHandle is 24 when I start the program on the console, and 0 when it starts as a
> service. Which means, StdOutputHandle doesn't get initialized in service mode! I don't know why is this - the older runtimes didn't
> have this problem. It's present since 2.6.2.
It does not necessarily mean this.
It can also mean that windows returns 0 as StdOutputHandle if the service manager has started the program,
depending on how the program was compiled (GUI or console app).
2.6.0 has been released in 2012.
The code that sets up stdin/out/etc hasn't changed at least since 2008-09-10 (and probably way before that).
and it is executed unconditionally.
Once more:
The RTL itself does no checks to see whether a program is a service or not, only whether the APPTYPE is console or GUI.
So maybe the IsConsole behaviour has changed.
Michael.
More information about the fpc-pascal
mailing list