Board index » cppbuilder » ** Command line arguments sent to WinMain()??????????????????????????

** Command line arguments sent to WinMain()??????????????????????????

I'm making a GUI application to be called as a .DLL or from another
application, however, I would like to send it parameters in the command
line. ce I believe I can do that in the LPSTR argument of the: WINAPI
WinMain(HINSTANCE, HINSTANCE, LPSTR cmdLine, int) ... that BCB sets up
for me.

However, if cmdLine contains the arguments, I'm having trouble getting
the form to see it suprisingly... The form class needs to have it
included, but I don't know how to initialize the form with this command
line.

Can I initialize it like: TForm *Form1(cmdLine) ... as long as I have a
constructor that allows this? I don't know, I'm pretty dumbfounded...

Any help would be greatly appreciated!

Thanks in advance,
Dana

 

Re:** Command line arguments sent to WinMain()??????????????????????????


Quote
Dana Reed wrote in message <34E37872.C5CA2...@capellatech.com>...
>Can I initialize it like: TForm *Form1(cmdLine) ... as long as I have a
>constructor that allows this? I don't know, I'm pretty dumbfounded...

Yep - you can (I quite often do) create new overloaded constructors to do
the job for me - just remember to leave the original ::ctor there also and
BCB won't complain.

Note: Please remove the word SPAMBLOCK from my eMail address if you wish to
mail me.

Re:** Command line arguments sent to WinMain()??????????????????????????


Quote
Peter Pavlovic <pe...@SPAMBLOCKnexsol.com> wrote:
>Dana Reed wrote in message <34E37872.C5CA2...@capellatech.com>...
>>Can I initialize it like: TForm *Form1(cmdLine) ... as long as I have a
>>constructor that allows this? I don't know, I'm pretty dumbfounded...
>Yep - you can (I quite often do) create new overloaded constructors to do
>the job for me - just remember to leave the original ::ctor there also and
>BCB won't complain.

In this case though, of getting the command line, I'd discourage it.

1. As Peter said, you still need the default constructor. This default
constructor will be used by all forms on the auto-create list, and all
forms that you create using Application->CreateForm.

2. The command line is something which conceptually relates to the whole
process and so is more naturally stored as a global variable.

3. It already is stored as a global variable. Use ParamStr[] to access it,
and ParamCount.

4. And even if you just wanted the command line, you can get it at any
point in your program with GetCommandLine(..)

--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. ljw1...@cam.ac.uk

Other Threads