Re: Console-based exe COM server
- From: "Brian Muth" <bmuth@xxxxxxxx>
- Date: Wed, 14 Jan 2009 15:56:50 -0800
"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message news:OVKTHkpdJHA.5412@xxxxxxxxxxxxxxxxxxxxxxx
Leo <Leo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:Is it possible to create a console-based exe COM server, as opposed
to a window-based one?
Yes, but your users probably won't enjoy a console window suddenly appearing on their screen.
The only difference between a console and a GUI application is whether it's associated with a console on startup. A console application can happily create windows, and a GUI application can create a console.
Using ATL, if you use the "module" attribute
with a type of "exe" it generates the entry-point for WinMain, not
main. Is there anything that I can do to ensure that my exe COM
server is console-based with a main entry point, and accepts input
parameters and prints messages to the console (and still registers
via /regserver)?
Rather than fighting the wizard all the way, it might be easier to leave your app as GUI but allocate a console. See
http://support.microsoft.com/kb/199060
The problem described in the article is irrelevant to you, but the sample at the bottom shows how to use AllocConsole and freopen to set up a console in the GUI app.
If you want to accept input from the console, you would probably need to spin a new thread to do that.
--
With best wishes,
Igor Tandetnik
Better yet, stick with WinMain and fetch the command line directly using GetCommandLine. You can use CommandLineToArgvW to parse the command line and establish the argv and argv arguments just as if main() was called.
.
- References:
- Console-based exe COM server
- From: Leo
- Re: Console-based exe COM server
- From: Igor Tandetnik
- Console-based exe COM server
- Prev by Date: Re: Console-based exe COM server
- Next by Date: Re: Dynamically creating COM windows services
- Previous by thread: Re: Console-based exe COM server
- Next by thread: Re: Console-based exe COM server
- Index(es):
Relevant Pages
|