Brain,
I did exactly the same, but while running the application under cmd in
XP,
a new console window fashes. ie. a console window gets created and
exits without displaying any messages.
And i tried what Chris suggested, as you said a console window gets
created when running the app without any arguments.
Any more suggesions.
Max
"Brian Gideon" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Max,
>
> [DllImport("kernel32.dll")]
> public static extern bool AllocConsole();
>
> [DllImport("kernel32.dll")]
> public static extern bool FreeConsole();
>
> public static void Main(string[] args)
> {
> if (args.Length > 0)
> {
> AllocConsole();
> try
> {
> // Place console version of code here.
> }
> finally
> {
> FreeConsole();
> }
> }
> else
> {
> // Place windows version of code here.
> }
> }
>
> There's also an AttachConsole API that you might want to play around
> with.
>
> Brian
>
> Max wrote:
> > Hi All,
> >
> > I am developing an application that needs to run in one of two modes:
> > 1. If No command line param is provided the application should run as
> > Window form.
> > 2. If command line param is provided the application should run as a
> > console application.
> >
> > For this i created a windows application with Main
> >
> > static void Main(string[] cmdLine)
> > {
> > Form1 frm = new Form1();
> > if(cmdLine.Length == 0)
> > {
> > frm.InitializeForm();
> > Application.Run(frm);
> > }
> > else
> > {
> > frm.ProcessCommandline(cmdLine);
> > }
> > }
> >
> > Problem i have is "Console.writeline" does not work while running the
> > application as console ie running the application with params.
> >
> > Pls help
> >
> > thanks in advance
> >
> > regards
> >
> > Max
|