Board index » cppbuilder » Command line args to a GUI app?

Command line args to a GUI app?

Quote
Phil V wrote:
> Where in my Windows Gui program do I pick up the command line arguments
> passed to it and how?

In unit System you have available CmdLine, ParamCount and ParamStr[index].

<quote from Borland help file>
The following example beeps once for each beep passed in on the
command line. The example terminates the application if  exit is
passed in on the command line.

void __fastcall TForm1::FormCreate(TObject *Sender)

{
   for (int i=0;i<=ParamCount();i++)
   {
     if (LowerCase(ParamStr(i)) == "beep")
       Beep(10000,1000);
     else if (LowerCase(ParamStr(i)) == "exit")
       Application->Terminate();
   }

Quote
}

</quote>

--
   See me at http://nigel.eke.name/
[ Note: return address anti-spammed, sorry: _at_ and _dot_ ]

 

Re:Command line args to a GUI app?


Quote
Phil V wrote:
> Where in my Windows Gui program do I pick up the command line arguments
> passed to it and how?

Use the lpCmdLine argument pased to your WinMain() or with Builder
ParamStr and ParamCount or even, if you #include <dos.h>, _argc et
_argv. All this is in the online help.

Michel
--
----------------------------------------
Michel Leunen
mailto:mic...@leunen.com
http://www.leunen.com/cbuilder/
----------------------------------------

Re:Command line args to a GUI app?


Where in my Windows Gui program do I pick up the command line arguments
passed to it and how?

Thanks,

Phil

--

"If it is called software, why is it so hard?" - Unknown

Re:Command line args to a GUI app?


Thanks

search the help file, but was looking for things like arc and arv, I guess
it is one of those things that is easy to find when you know what you are
looking for

Phil

Quote
"Nigel Eke" <nige...@spameke.name> wrote in message

news:3e92a4f3@newsgroups.borland.com...
Quote
> Phil V wrote:
> > Where in my Windows Gui program do I pick up the command line arguments
> > passed to it and how?

> In unit System you have available CmdLine, ParamCount and ParamStr[index].

> <quote from Borland help file>
> The following example beeps once for each beep passed in on the
> command line. The example terminates the application if  exit is
> passed in on the command line.

> void __fastcall TForm1::FormCreate(TObject *Sender)

> {
>    for (int i=0;i<=ParamCount();i++)
>    {
>      if (LowerCase(ParamStr(i)) == "beep")
>        Beep(10000,1000);
>      else if (LowerCase(ParamStr(i)) == "exit")
>        Application->Terminate();
>    }
> }
> </quote>

> --
>    See me at http://nigel.eke.name/
> [ Note: return address anti-spammed, sorry: _at_ and _dot_ ]

Other Threads