parameters
-
oh, you are wanting what are the arguments that a program can have/use, no ? I think that for normal DOS type programs, you can do somthing like
cmd.exe /?
which will list the available arguments. maybe some program will have the following format :someprogram.exe -h
orsomeprogram.exe --help
Maximilien Lincourt Your Head A Splode - Strong Bad
Its a Win32 program. So, is it possible to get arguments through VC++ or something?
-
FOR EXAMPLE: This testfile.exe is normaly running in fullscreen. But it has parameters wich can be used to run it in a small windows size. The problem is: How do you get those parameters?
-Dy has answered this particular question.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
thanks Its parameter the right name for this?
Technically there is a difference between parameters and arguments. Most folks use them interchangeably, and thus can lead to confusion.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
Technically there is a difference between parameters and arguments. Most folks use them interchangeably, and thus can lead to confusion.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
How do you call this what I want? arguments or parameters?
-
How do you call this what I want? arguments or parameters?
void foo( int x ) // the parameter is x
{
}void main( int argc, char *argv ) // the parameters are argc and argv
{
foo(123); // the argument is 123
}if this program were started at a command prompt like myprog.exe -excavator, the argument would be -excavator.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
FOR EXAMPLE: This testfile.exe is normaly running in fullscreen. But it has parameters wich can be used to run it in a small windows size. The problem is: How do you get those parameters?
-
CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); cmdInfo.m_strFileName now contains the commandline.
rwilmink wrote: cmdInfo.m_strFileName now contains the commandline. Only in specific instances (i.e., if the shell command is New or DDE). If you specified an argument that was not recognized by
CCommandLineInfo
, it would not show up in any of the member variables.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
you need to do this from the source code, not from the command line ( or if that's the case, juste copy paste the arguments ) from the a simple C or C++ source code :
int main ( int argc, char* argv[] ) { /// argc is the number of arguments /// argv is the string containing the arguments. /// argv[0] is the program /// from argv[1] are the arguments /// you need to parse them manually. }
from a MFC application :BOOL YouApp::InitInstance() { /// use the CCommandLineInfo class. CCommandLineInfo cmdLineInfo; }
Maximilien Lincourt Your Head A Splode - Strong Bad
You can access __argc and __argv in Win32 applications also. This is what MFC does in CCommandLineInfo and why I rarely use it myself. You end up peeling the args back apart so I see little point to it. BTW - if you don't believe me then check the MFC source code. :)
-
rwilmink wrote: cmdInfo.m_strFileName now contains the commandline. Only in specific instances (i.e., if the shell command is New or DDE). If you specified an argument that was not recognized by
CCommandLineInfo
, it would not show up in any of the member variables.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
Thank you very much for your suggestions. Could you tell me your theory how you think it should be done?
-
Thank you very much for your suggestions. Could you tell me your theory how you think it should be done?
As was mentioned here, -Dy has already answered your question for both MFC and non-MFC. What else are you looking for?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
As was mentioned here, -Dy has already answered your question for both MFC and non-MFC. What else are you looking for?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
oh ok thats it thank you