예제 #1
0
/// \retval false App should not be started
/// \retval true App can be started
bool App::ParseCommandLine()
{
   ProgramOptions options;

   options.RegisterOutputHandler(&ProgramOptions::OutputConsole);
   options.RegisterHelpOption();

   options.RegisterParameterHandler([&](const CString& cszFilename)-> bool
   {
      // only take first filename
      if (m_cszFilename.IsEmpty())
         m_cszFilename = cszFilename;
      return true;
   });

   options.Parse(GetCommandLine());

   return !options.IsSelectedHelpOption();
}
예제 #2
0
/// \retval false App should not be started
/// \retval true App can be started
bool App::ParseCommandLine()
{
   ProgramOptions options;

   options.RegisterOutputHandler(&ProgramOptions::OutputConsole);
   options.RegisterHelpOption();

   bool bStartApp = true;

   options.RegisterOption(_T("r"), _T("register-wia"), _T("registers WIA handler for RemotePhotoTool"),
      0, [&](const std::vector<CString>&)
   {
      RegisterWIAHandler(true); bStartApp = false; return true;
   });

   options.RegisterOption(_T("u"), _T("unregister-wia"), _T("unregisters WIA handler for RemotePhotoTool"),
      0, [&](const std::vector<CString>&)
   {
      RegisterWIAHandler(false); bStartApp = false; return true;
   });

   options.RegisterOption(_T("o"), _T("open-wia"), _T("opens camera using WIA handler; <arg1>: Port, <arg2>: Guid"),
      2, [&](const std::vector<CString>& vecArgs)
   {
      vecArgs;
      ATLASSERT(vecArgs.size() == 2);
      // just let the app start here
      return true;
   });

   options.Parse(GetCommandLine());

   if (!bStartApp || options.IsSelectedHelpOption())
      return false;

   return true;
}