How to make an EXE that's both WinForms _and_ command-line ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to make an application that has both a WinForms interface _and_ a
command-line interface (using C#). I'm having some success, with the
following limitations:

If I compile it as a WinExe I get no command-line functionality. (Although
Console output can be redirected to a file.)

If I compile it as a console app, I get the console functionality _and_ the
WinForms functionality (YAY!), but...

When the app is executed from an icon (or menu or whatever) the console
window displays along with the WinForms window (yuck).

So...

How can I hide the "DOS window" when a console app executes from Windows?

I think that having the console app minimize its main window and not display
a button in the task bar will be enough.
 
Try this (not my code, see below for cite):

[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool FreeConsole();

[STAThread]
static void Main(string[] args)
if( args.Length == 0 )
{
// This seems to get rid of the console window before it's show
FreeConsole();

// Themed controls
Application.EnableVisualStyles();
Application.DoEvents();


// Run the GUI version of the application
Application.Run(new CGUIVersion());
}
else
{
// Run the console version of the application
CConsoleVersion.DoOp( args );
}


It's from here
Shrunken URL:
http://shrinkster.com/35v

URL:
http://groups-beta.google.com/group..._doneTitle=Back+to+Search&&d#a6fbe198fe332c91
 
Back
Top