Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.1 KiB

  1. /*++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1981 - 1999
  4. Module Name:
  5. commandline.cpp
  6. Abstract:
  7. Author:
  8. Rahul Thombre (RahulTh) 4/30/1998
  9. Revision History:
  10. 4/30/1998 RahulTh
  11. Created this module.
  12. --*/
  13. // CommandLine.cpp: implementation of the CCommandLine class.
  14. //
  15. //////////////////////////////////////////////////////////////////////
  16. #include "precomp.hxx"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. //////////////////////////////////////////////////////////////////////
  23. // Construction/Destruction
  24. //////////////////////////////////////////////////////////////////////
  25. CCommandLine::CCommandLine() : m_fInvalidParams(FALSE), m_iListLen(0),
  26. m_fHideApp (FALSE), m_fShowSettings(FALSE),
  27. m_fFilesProvided (FALSE), m_lpszFilesList(NULL)
  28. {
  29. }
  30. CCommandLine::~CCommandLine()
  31. {
  32. if (m_lpszFilesList)
  33. delete [] m_lpszFilesList;
  34. }
  35. void CCommandLine::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
  36. {
  37. TCHAR* lpszTemp;
  38. if(bFlag)
  39. {
  40. if (!lstrcmp(lpszParam, TEXT("h")) || !lstrcmp(lpszParam, TEXT("H")))
  41. m_fHideApp = TRUE;
  42. else if (!lstrcmp(lpszParam, TEXT("s")) || !lstrcmp(lpszParam, TEXT("S")))
  43. m_fShowSettings = TRUE;
  44. else
  45. m_fInvalidParams = TRUE;
  46. }
  47. else //lpszParam is a file/folder name.
  48. {
  49. m_fFilesProvided = TRUE;
  50. m_FileNames = m_FileNames + lpszParam + "\""; //use quotes as filename separator for now.
  51. }
  52. if (bLast && m_fFilesProvided) //invalid combination of parameters
  53. if (m_fShowSettings)
  54. m_fInvalidParams = TRUE;
  55. else
  56. {
  57. m_lpszFilesList = new TCHAR[m_iListLen = (lstrlen((LPCTSTR)m_FileNames) + 1)];
  58. lstrcpy(m_lpszFilesList, LPCTSTR(m_FileNames));
  59. for (lpszTemp = m_lpszFilesList; *lpszTemp; lpszTemp++)
  60. if ('\"' == *lpszTemp)
  61. *lpszTemp = '\0'; //create a null separated list of files
  62. }
  63. }