Jun 11, 2003 #1 scienzia Programmer Joined Feb 21, 2002 Messages 160 Location IT Hi, I would like to know how to take parameters from command line running. I mean I want to be able to run my application by DOS like this: > MyApp -x -a and get the parameters inside the application. Thanks in advance.
Hi, I would like to know how to take parameters from command line running. I mean I want to be able to run my application by DOS like this: > MyApp -x -a and get the parameters inside the application. Thanks in advance.
Jun 11, 2003 #2 Wiggis Programmer Joined Jun 9, 2003 Messages 10 Location GB the int main(int argc, char* argv[]) method stores all command line arguments in the argv[] array you can then access them the same way you would normally access members of an array, just make sure the parameter exists before you try and access it Upvote 0 Downvote
the int main(int argc, char* argv[]) method stores all command line arguments in the argv[] array you can then access them the same way you would normally access members of an array, just make sure the parameter exists before you try and access it
Jun 13, 2003 Thread starter #3 scienzia Programmer Joined Feb 21, 2002 Messages 160 Location IT I'm sorry my post missed some informations... I'm talking abount MFC, and I didn't find anything similar to Code: int main(int argc, char* argv[]) [\code] Upvote 0 Downvote
I'm sorry my post missed some informations... I'm talking abount MFC, and I didn't find anything similar to Code: int main(int argc, char* argv[]) [\code]
Jun 13, 2003 #4 CMR Programmer Joined Apr 30, 2002 Messages 76 Location AU Check out the CCommandLineInfo class. You can create a new class that inherits from this and add specific command line handlers by overriding the "ParseParam()" member function. CMR Upvote 0 Downvote
Check out the CCommandLineInfo class. You can create a new class that inherits from this and add specific command line handlers by overriding the "ParseParam()" member function. CMR
Jun 13, 2003 #5 BEHZADTALA Programmer Joined May 28, 2003 Messages 43 Location DE Hi, you can use ::GetCommandLine() function and then if you want you can convert the LPSTR result to argv and argc with the CommandLineToArgvW() brgd Upvote 0 Downvote
Hi, you can use ::GetCommandLine() function and then if you want you can convert the LPSTR result to argv and argc with the CommandLineToArgvW() brgd