Re: Console-based exe COM server

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"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.



.



Relevant Pages

  • Re: Which distro for a server?
    ... > everything that I need with only a text console. ... > that doesn't exactly help me in learning linux on my own. ... command line commands or names of configuration files - field-based editing ... me a virtually seamless full screen linux GUI. ...
    (comp.os.linux)
  • Re: tkcon in a C application
    ... Good - so you would have access to GUI components to build a prompt. ... command, show prompt, catch errors and print them). ... MFC CEdit GUI component to create a MFC tcl console. ...
    (comp.lang.tcl)
  • Re: Win32 app - console vs. GUI modes
    ... Such programs have two executable files: one (GUI) with .EXE extension to ... .EXE file of PE format, anyway), which gets started if you type its name in ... > were executed in a console command prompt window or by the Windows ... > window, the program had full access to the STDIN, STDOUT and STDERR ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Hiding console window fails - Windows Vista specific
    ... If AttachConsole does what you want and the only problem is that the batch file doesn't block, you can use the start /wait command. ... the console window stays ... ...
    (microsoft.public.win32.programmer.kernel)
  • Re: umount
    ... Doesn't your GUI show a 'console' window? ... Although the messages may 'come from' the kernel, ...
    (Linux-Kernel)