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.

224 lines
6.1 KiB

  1. /****************************************************************************
  2. Copyright information : Copyright (c) 1998-1999 Microsoft Corporation
  3. File Name : WMICommandLn.h
  4. Project Name : WMI Command Line
  5. Author Name : Ch.Sriramachandramurthy
  6. Date of Creation (dd/mm/yy) : 27th-September-2000
  7. Version Number : 1.0
  8. Brief Description : This file consist of class declaration of
  9. class CWMICommandLine
  10. Revision History :
  11. Last Modified By : Ch. Sriramachandramurthy
  12. Last Modified Date : 16th-January-2001
  13. ****************************************************************************/
  14. // WMICommandLine.h : header file
  15. //
  16. /*-------------------------------------------------------------------
  17. Class Name : CWMICommandLine
  18. Class Type : Concrete
  19. Brief Description : This class encapsulates the functionality needed
  20. for synchronization the funtionality of three
  21. functional components identified for the WmiCli.exe.
  22. Super Classes : None
  23. Sub Classes : None
  24. Classes Used : CParsedInfo
  25. CExecEngine
  26. CFormatEngine
  27. CParserEngine
  28. Interfaces Used : WMI COM Interfaces
  29. --------------------------------------------------------------------*/
  30. // forward declaration of classes
  31. class CParserEngine;
  32. class CExecEngine;
  33. class CFormatEngine;
  34. class CParsedInfo;
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CWMICommandLine
  37. class CWMICommandLine
  38. {
  39. public:
  40. // Construction
  41. CWMICommandLine();
  42. // Destruction
  43. ~CWMICommandLine();
  44. // Restrict Assignment
  45. CWMICommandLine& operator=(CWMICommandLine& rWmiCmdLn);
  46. // Attributes
  47. private:
  48. //Pointer to the locator object .
  49. IWbemLocator *m_pIWbemLocator;
  50. //CParserEngine object
  51. CParserEngine m_ParserEngine;
  52. //CExecEngine object
  53. CExecEngine m_ExecEngine;
  54. //CFormatEngine object
  55. CFormatEngine m_FormatEngine;
  56. //CParsedInfo object
  57. CParsedInfo m_ParsedInfo;
  58. // error level
  59. WMICLIUINT m_uErrLevel;
  60. // handle to registry key
  61. HKEY m_hKey;
  62. // handle Ctrl+ events
  63. BOOL m_bBreakEvent;
  64. // specifies accepting input (==TRUE) or executing command (==FALSE)
  65. BOOL m_bAccCmd;
  66. // << description to be added >>
  67. BOOL m_bDispRes;
  68. // Flag to specify windows socket interface initialization.
  69. BOOL m_bInitWinSock;
  70. // Buffer to hold data to be send to clipboard.
  71. _bstr_t m_bstrClipBoardBuffer;
  72. // added by (Nag)
  73. BSTRMAP m_bmKeyWordtoFileName;
  74. // Height of console buffer before starting utility.
  75. SHORT m_nHeight;
  76. // Width of console buffer before starting utility.
  77. SHORT m_nWidth;
  78. // Operations
  79. public:
  80. // Does the initialization ofthe COM library and the security
  81. // at the process level
  82. BOOL Initialize();
  83. //Gets the Format Engine Object
  84. CFormatEngine& GetFormatObject();
  85. //Gets the Parse Information Object
  86. CParsedInfo& GetParsedInfoObject();
  87. //Uninitializes the the member variables when the execution of a
  88. //command string issued on the command line is completed.
  89. void Uninitialize();
  90. //processes the given command string
  91. SESSIONRETCODE ProcessCommandAndDisplayResults(_TCHAR* pszBuffer);
  92. //Puts the process to a wait state, launches a worker thread
  93. //that keeps track of kbhit()
  94. void SleepTillTimeoutOrKBhit(DWORD dwMilliSeconds);
  95. //Thread procedure polling for keyboard hit
  96. static DWORD WINAPI PollForKBhit(LPVOID lpParam);
  97. //Function to check whether the input string's first token
  98. //is 'quit'|'exit', if so return true else return false.
  99. BOOL IsSessionEnd();
  100. //Set the session error value
  101. void SetSessionErrorLevel(SESSIONRETCODE ssnRetCode);
  102. //Get the session error value
  103. WMICLIUINT GetSessionErrorLevel();
  104. // This function check whether the /USER global switch
  105. // has been specified without /PASSWORD, if so prompts
  106. // for the password
  107. void CheckForPassword();
  108. // Checks whether the given namespace is available or not.
  109. BOOL IsNSAvailable(const _bstr_t& bstrNS);
  110. // Checks whether the wmic.exe is being launched for the first time.
  111. BOOL IsFirstTime();
  112. // Register the aliases info / localized descriptions
  113. HRESULT RegisterMofs();
  114. // Compile the MOF file.
  115. HRESULT CompileMOFFile(IMofCompiler* pIMofComp,
  116. const _bstr_t& bstrFile,
  117. WMICLIINT& nErr);
  118. // Set break event falg
  119. void SetBreakEvent(BOOL bFlag);
  120. // Get break event flag
  121. BOOL GetBreakEvent();
  122. // Set Accept Command flag
  123. void SetAcceptCommand(BOOL bFlag);
  124. // Get Accept Command flag
  125. BOOL GetAcceptCommand();
  126. // Set displayresults flag status
  127. void SetDisplayResultsFlag(BOOL bFlag);
  128. // Get DisplayResults flag status
  129. BOOL GetDisplayResultsFlag();
  130. // Set Windows sockect interface flag
  131. void SetInitWinSock(BOOL bFlag);
  132. // Get Windows sockect interface flag
  133. BOOL GetInitWinSock();
  134. // Buffer data to send clipboard.
  135. void AddToClipBoardBuffer(LPSTR pszOutput);
  136. // Get Buffered output in clip board buffer.
  137. _bstr_t& GetClipBoardBuffer();
  138. // Clear Clip Board Buffer.
  139. void EmptyClipBoardBuffer();
  140. // Check if the file is xml or batch file. If it is batch file
  141. // then parse it, get commands and write the commands into
  142. // batch file and redirect the stdin to that file.
  143. BOOL ReadXMLOrBatchFile(HANDLE hInFile);
  144. // Frames the XML string for context info
  145. void FrameContextInfoFragment(_bstr_t& bstrContext);
  146. // Frames the XML header info
  147. void FrameNodeListFragment(_bstr_t& bstrNodeList);
  148. // Frames the XML string for Request info
  149. void FrameXMLHeader(_bstr_t& bstrHeader, WMICLIINT nIter);
  150. // Frames the XML string for NodeList info
  151. void FrameRequestNode(_bstr_t& bstrRequest);
  152. // Frames the XML string for commandline info
  153. void FrameCommandLineComponents(_bstr_t& bstrCommandComponent);
  154. // Frames the XML string for formats info
  155. void FrameFormats(_bstr_t& bstrFormats);
  156. // Frames the XML string for properties info
  157. void FramePropertiesInfo(_bstr_t& bstrProperties);
  158. // Gets the xslfile name corrsponding to the keyword passed
  159. // from the BSTRMAP
  160. BOOL GetFileFromKey(_bstr_t bstrkeyName, _bstr_t& bstrFileName);
  161. // Frames the BSTR Map contains the key words and
  162. // corresponding files from the XSL mapping file
  163. void GetFileNameMap();
  164. // Get the XSL file names for keywords
  165. void GetXSLMappings(_TCHAR *pszFilePath);
  166. };