CommandLineInfoEx.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "StdAfx.h"
  2. #include "CommandLineInfoEx.h"
  3. CCommandLineInfoEx::CCommandLineInfoEx(void)
  4. {
  5. }
  6. CCommandLineInfoEx::~CCommandLineInfoEx(void)
  7. {
  8. }
  9. bool CCommandLineInfoEx::GetWindowHandle(string& strWindowHandle)
  10. {
  11. strWindowHandle = m_strWindow;
  12. if (strWindowHandle.length() == 0)
  13. {
  14. return false;
  15. }
  16. return true;
  17. }
  18. void CCommandLineInfoEx::ParseCommandLine(CCommandLineInfoEx& rCmdInfo)
  19. {
  20. for (int i = 0; i < __argc; i++)
  21. {
  22. LPCTSTR pszParam = __targv[i];
  23. rCmdInfo.ParseParam(pszParam);
  24. }
  25. }
  26. void CCommandLineInfoEx::ParseParam(const TCHAR* pszParam)
  27. {
  28. if (ParseWindow(pszParam, m_strWindow))
  29. {
  30. }
  31. else if (ParseBatchID(pszParam, m_strBatchID))
  32. {
  33. }
  34. }
  35. BOOL CCommandLineInfoEx::ParseWindow(string strUrl, string& strWindow)
  36. {
  37. const string strKey = "window=";
  38. int nPos = strUrl.find(strKey);
  39. if (nPos < 0)
  40. {
  41. return FALSE;
  42. }
  43. nPos += strKey.length();
  44. if (nPos >= (int)strUrl.length())
  45. {
  46. return FALSE;
  47. }
  48. strWindow = strUrl.substr(nPos);
  49. return TRUE;
  50. }
  51. BOOL CCommandLineInfoEx::ParseBatchID(string strUrl, string& strBatchID)
  52. {
  53. const string strKey = "batchid=";
  54. int nPos = strUrl.find(strKey);
  55. if (nPos < 0)
  56. {
  57. return FALSE;
  58. }
  59. nPos += strKey.length();
  60. if (nPos >= (int)strUrl.length())
  61. {
  62. return FALSE;
  63. }
  64. strBatchID = strUrl.substr(nPos);
  65. return TRUE;
  66. }