Processing Arguments of the Command Line

[This is preliminary documentation and subject to change.]

One of the first operations your application must perform is to parse the arguments of the command line obtained from Tvwakeup.exe or from your own wake-up application. Your application requires parsing these arguments to process them. The best way to parse these arguments is when your application initializes. If you write your application in Microsoft® Foundation Classes (MFC), you should create a command-line class that inherits from the CCommandLineInfo class and override the ParseParam method. During your application's InitInstance method, your application should create an instance of the command-line object. Your application should then call the ParseCommandLine method of the CWinApp class from which your application inherits and pass the command-line object. The ParseCommandLine method then parses and passes each argument in the command line to the ParseParam method that you implement. After ParseParam fills the command-line object, your application passes the command-line object to the ProcessShellCommand method of the CWinApp class. ProcessShellCommand then handles the command-line arguments and flags to perform the indicated operation.

The ParseParam method that you implement should evaluate the arguments of the command line and process them according to whether they are specific flags or functions or the final argument of the command line. Your ParseParam method should create static variables that will store the most recently passed flag argument and a boolean value indicating whether or not ParseCommandLine passed the command to begin recording. If your ParseParam method receives an argument and determines that the static flag variable holds a function flag, ParseParam should evaluate the argument according to the operation specified. If the argument specifies to start recording, ParseParam should set the static boolean value for recording. If the argument specifies to end recording, ParseParam should send a command to stop recording. If your ParseParam method receives an argument and determines that the static flag variable holds a channel flag, ParseParam should evaluate the argument and send commands to the remote control to tune the VCR. If your ParseParam method determines that it received the final argument and that its static boolean value was set for recording, ParseParam should send a command to start recording.