Input from Commandline.
-
HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.
-
HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.
What about using
GetCommandLine()
?Life is a stage and we are all actors!
-
HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.
I use this, from right here on CP CCmdLine - command line parser[^] 'g'
-
HI, I written one application using MFC Appwizard exe.In that application iam browsing a file in my PC and Parsing into required form and loading in a database table. Till now my application working fine. But the requirement changed as i need to take the input from Commandline and need to Run the application as batch file. MY Requirement is i need to take two parameters in commandline one is File path and Another one is Table Name. I need your Guidance. Thanks, Krishna.
The official MFC way is to: - derive a class from CCommandLineInfo and overide CCommandLineInfo::ParseParam - call CWinApp::ParseCommandLine in your overide of CWinApp::InitInstance using an instance of your class derived from CCommandLineInfo. When a new instance of your application starts CWinApp::ParseCommandLine slices the command line into tokens and chucks each on in turn into "YourDerivedClass"::ParseParam. ParseParam can do whatever it likes with the tokens it gets - raise or lower flags, set global state, you name it. If you want a simple class to explore these concepts try this for size:
class simple_command_line_parser : public CCommandLineInfo
{
public:
void ParseParam( const wchar_t* parameter, BOOL, BOOL )
{
::AfxMessageBox( parameter );
}
};All it does is display the parameters it recieves in a message box. You'd use it by adding the following two line to your App's InitInstance:
simple\_command\_line\_parser sclp; ParseCommandLine( sclp );
Anyway, hope that helps! Ash