From: Grant E. <gr...@vi...> - 2008-01-23 18:55:28
|
On 2008-01-23, Daniel Pryden <da...@pr...> wrote: >> So a windows _executable_ is either a windows program which >> can't have a stdin/stdout/stderr even when started from a >> console, or a console program which _must_ have a >> stdin/stdout/stderr even it never uses them? > > The problem actually lies with the Windows SDK, which (by > convention, but very entrenched convention) uses an entrypoint > called WinMain() instead of the standard C main(). One of the > arguments to WinMain() is a HINSTANCE handle to your > application, which you will need if you create any windows > (since the OS needs to know which process owns the given > windows). Since WinMain() and main() define different > arguments, only one or the other gets called at startup, > depending on the EXE -- (and that's where my knowledge of how > Windows works gets fuzzy). I see: you provide a WinMain() entry point if you want an hInstance handle which is required to use the Windowing API. What doesn't make sens (to me) is why that has anything to do with whether or not the stdio handles are connected to anything. The prohibition against using stdin/out/err in a WinMain() app seems completely pointless and arbitrary (at least to a Unix native). > Here's a link: http://msdn2.microsoft.com/en-us/library/ms633559(VS.85).aspx Thanks. > Probably an easier solution would be to replace all your > stdout/stderr writes with something like the logging module. Yup, that's pretty much what I've done. -- Grant Edwards grante Yow! I wonder if there's at anything GOOD on tonight? visi.com |