Leaked source code of windows server 2003
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.

379 lines
13 KiB

  1. // MsieCtl.h : Declaration of the CMsieCtrl ActiveX Control class.
  2. #if !defined(AFX_MSIECTL_H__25959BFC_E700_11D2_A7AF_00C04F806200__INCLUDED_)
  3. #define AFX_MSIECTL_H__25959BFC_E700_11D2_A7AF_00C04F806200__INCLUDED_
  4. #if _MSC_VER >= 1000
  5. #pragma once
  6. #endif // _MSC_VER >= 1000
  7. #include <wbemprov.h>
  8. // MSInfo views for IE extension - must match values in Registry
  9. #define MSIVIEW_BEGIN 1
  10. #define MSIVIEW_SUMMARY 1
  11. #define MSIVIEW_FILE_VERSIONS 2
  12. #define MSIVIEW_CONNECTIVITY 3
  13. #define MSIVIEW_CACHE 4
  14. #define MSIVIEW_OBJECT_LIST 5
  15. #define MSIVIEW_CONTENT 6
  16. #define MSIVIEW_PERSONAL_CERTIFICATES 7
  17. #define MSIVIEW_OTHER_PEOPLE_CERTIFICATES 8
  18. #define MSIVIEW_PUBLISHERS 9
  19. #define MSIVIEW_SECURITY 10
  20. #define MSIVIEW_END 10
  21. #define CONNECTIVITY_BASIC_LINES 51
  22. #define ITEM_LEN 128
  23. #define VALUE_LEN MAX_PATH
  24. #define VERSION_LEN 20
  25. #define DATE_LEN 64
  26. #define SIZE_LEN 16
  27. #define STATUS_LEN 40
  28. typedef struct
  29. {
  30. UINT uiView;
  31. TCHAR szItem[ITEM_LEN];
  32. TCHAR szValue[VALUE_LEN];
  33. } LIST_ITEM;
  34. typedef struct
  35. {
  36. UINT uiView;
  37. TCHAR szItem[ITEM_LEN];
  38. TCHAR szValue[VALUE_LEN];
  39. BOOL bBold;
  40. } EDIT_ITEM;
  41. typedef struct
  42. {
  43. UINT uiView;
  44. TCHAR szFile[_MAX_FNAME];
  45. TCHAR szVersion[VERSION_LEN];
  46. TCHAR szSize[SIZE_LEN];
  47. TCHAR szDate[DATE_LEN];
  48. TCHAR szPath[VALUE_LEN];
  49. TCHAR szCompany[VALUE_LEN];
  50. DWORD dwSize;
  51. DATE date;
  52. } LIST_FILE_VERSION;
  53. typedef struct
  54. {
  55. UINT uiView;
  56. TCHAR szProgramFile[_MAX_FNAME];
  57. TCHAR szStatus[STATUS_LEN];
  58. TCHAR szCodeBase[MAX_PATH];
  59. } LIST_OBJECT;
  60. typedef struct
  61. {
  62. UINT uiView;
  63. TCHAR szIssuedTo[_MAX_FNAME];
  64. TCHAR szIssuedBy[_MAX_FNAME];
  65. TCHAR szValidity[_MAX_FNAME];
  66. TCHAR szSignatureAlgorithm[_MAX_FNAME];
  67. } LIST_CERT;
  68. typedef struct
  69. {
  70. UINT uiView;
  71. TCHAR szName[_MAX_FNAME];
  72. } LIST_NAME;
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CMsieCtrl : See MsieCtl.cpp for implementation.
  75. class CMsieCtrl : public COleControl
  76. {
  77. DECLARE_DYNCREATE(CMsieCtrl)
  78. // Constructor
  79. public:
  80. CMsieCtrl();
  81. // Overrides
  82. // ClassWizard generated virtual function overrides
  83. //{{AFX_VIRTUAL(CMsieCtrl)
  84. public:
  85. virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
  86. virtual void DoPropExchange(CPropExchange* pPX);
  87. virtual void OnResetState();
  88. virtual void Serialize(CArchive& ar);
  89. protected:
  90. virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  91. //}}AFX_VIRTUAL
  92. // Implementation
  93. protected:
  94. ~CMsieCtrl();
  95. DECLARE_OLECREATE_EX(CMsieCtrl) // Class factory and guid
  96. DECLARE_OLETYPELIB(CMsieCtrl) // GetTypeInfo
  97. DECLARE_PROPPAGEIDS(CMsieCtrl) // Property page IDs
  98. DECLARE_OLECTLTYPE(CMsieCtrl) // Type name and misc status
  99. // Message maps
  100. //{{AFX_MSG(CMsieCtrl)
  101. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  102. afx_msg void OnSize(UINT nType, int cx, int cy);
  103. afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  104. //}}AFX_MSG
  105. DECLARE_MESSAGE_MAP()
  106. void OnBasicBtnClicked();
  107. void OnAdvancedBtnClicked();
  108. // Dispatch maps
  109. //{{AFX_DISPATCH(CMsieCtrl)
  110. long m_MSInfoView;
  111. afx_msg void OnMSInfoViewChanged();
  112. afx_msg void MSInfoRefresh(BOOL fForSave, long FAR* pCancel);
  113. afx_msg BOOL MSInfoLoadFile(LPCTSTR szFileName);
  114. afx_msg void MSInfoSelectAll();
  115. afx_msg void MSInfoCopy();
  116. afx_msg void MSInfoUpdateView();
  117. afx_msg long MSInfoGetData(long dwMSInfoView, long FAR* pBuffer, long dwLength);
  118. //}}AFX_DISPATCH
  119. DECLARE_DISPATCH_MAP()
  120. // Interface maps
  121. DECLARE_INTERFACE_MAP()
  122. // IWbemProviderInit
  123. BEGIN_INTERFACE_PART(WbemProviderInit, IWbemProviderInit)
  124. STDMETHOD(Initialize)(
  125. /* [in] */ LPWSTR pszUser,
  126. /* [in] */ LONG lFlags,
  127. /* [in] */ LPWSTR pszNamespace,
  128. /* [in] */ LPWSTR pszLocale,
  129. /* [in] */ IWbemServices *pNamespace,
  130. /* [in] */ IWbemContext *pCtx,
  131. /* [in] */ IWbemProviderInitSink *pInitSink);
  132. STDMETHOD(GetByPath)(BSTR Path, IWbemClassObject FAR* FAR* pObj, IWbemContext *pCtx) {return WBEM_E_NOT_SUPPORTED;};
  133. END_INTERFACE_PART(WbemProviderInit)
  134. //IWbemServices
  135. BEGIN_INTERFACE_PART(WbemServices, IWbemServices)
  136. STDMETHOD(OpenNamespace)(
  137. /* [in] */ const BSTR Namespace,
  138. /* [in] */ long lFlags,
  139. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  140. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  141. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) {return WBEM_E_NOT_SUPPORTED;};
  142. STDMETHOD(CancelAsyncCall)(
  143. /* [in] */ IWbemObjectSink __RPC_FAR *pSink) {return WBEM_E_NOT_SUPPORTED;};
  144. STDMETHOD(QueryObjectSink)(
  145. /* [in] */ long lFlags,
  146. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  147. STDMETHOD(GetObject)(
  148. /* [in] */ const BSTR ObjectPath,
  149. /* [in] */ long lFlags,
  150. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  151. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  152. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  153. STDMETHOD(GetObjectAsync)(
  154. /* [in] */ const BSTR ObjectPath,
  155. /* [in] */ long lFlags,
  156. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  157. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;};
  158. STDMETHOD(PutClass)(
  159. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  160. /* [in] */ long lFlags,
  161. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  162. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  163. STDMETHOD(PutClassAsync)(
  164. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  165. /* [in] */ long lFlags,
  166. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  167. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  168. STDMETHOD(DeleteClass)(
  169. /* [in] */ const BSTR Class,
  170. /* [in] */ long lFlags,
  171. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  172. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  173. STDMETHOD(DeleteClassAsync)(
  174. /* [in] */ const BSTR Class,
  175. /* [in] */ long lFlags,
  176. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  177. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  178. STDMETHOD(CreateClassEnum)(
  179. /* [in] */ const BSTR Superclass,
  180. /* [in] */ long lFlags,
  181. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  182. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  183. STDMETHOD(CreateClassEnumAsync)(
  184. /* [in] */ const BSTR Superclass,
  185. /* [in] */ long lFlags,
  186. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  187. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  188. STDMETHOD(PutInstance)(
  189. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  190. /* [in] */ long lFlags,
  191. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  192. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  193. STDMETHOD(PutInstanceAsync)(
  194. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  195. /* [in] */ long lFlags,
  196. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  197. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  198. STDMETHOD(DeleteInstance)(
  199. /* [in] */ const BSTR ObjectPath,
  200. /* [in] */ long lFlags,
  201. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  202. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) {return WBEM_E_NOT_SUPPORTED;};
  203. STDMETHOD(DeleteInstanceAsync)(
  204. /* [in] */ const BSTR ObjectPath,
  205. /* [in] */ long lFlags,
  206. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  207. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  208. STDMETHOD(CreateInstanceEnum)(
  209. /* [in] */ const BSTR Class,
  210. /* [in] */ long lFlags,
  211. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  212. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  213. STDMETHOD(CreateInstanceEnumAsync)(
  214. /* [in] */ const BSTR Class,
  215. /* [in] */ long lFlags,
  216. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  217. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  218. STDMETHOD(ExecQuery)(
  219. /* [in] */ const BSTR QueryLanguage,
  220. /* [in] */ const BSTR Query,
  221. /* [in] */ long lFlags,
  222. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  223. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  224. STDMETHOD(ExecQueryAsync)(
  225. /* [in] */ const BSTR QueryLanguage,
  226. /* [in] */ const BSTR Query,
  227. /* [in] */ long lFlags,
  228. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  229. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  230. STDMETHOD(ExecNotificationQuery)(
  231. /* [in] */ const BSTR QueryLanguage,
  232. /* [in] */ const BSTR Query,
  233. /* [in] */ long lFlags,
  234. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  235. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) {return WBEM_E_NOT_SUPPORTED;};
  236. STDMETHOD(ExecNotificationQueryAsync)(
  237. /* [in] */ const BSTR QueryLanguage,
  238. /* [in] */ const BSTR Query,
  239. /* [in] */ long lFlags,
  240. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  241. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) {return WBEM_E_NOT_SUPPORTED;};
  242. STDMETHOD(ExecMethod)(const BSTR, const BSTR, long, IWbemContext*,
  243. IWbemClassObject*, IWbemClassObject**, IWbemCallResult**) {return WBEM_E_NOT_SUPPORTED;}
  244. STDMETHOD(ExecMethodAsync)(const BSTR, const BSTR, long,
  245. IWbemContext*, IWbemClassObject*, IWbemObjectSink*) {return WBEM_E_NOT_SUPPORTED;}
  246. END_INTERFACE_PART(WbemServices)
  247. // Event maps
  248. //{{AFX_EVENT(CMsieCtrl)
  249. //}}AFX_EVENT
  250. DECLARE_EVENT_MAP()
  251. // Dispatch and event IDs
  252. public:
  253. enum {
  254. //{{AFX_DISP_ID(CMsieCtrl)
  255. dispidMSInfoView = 1L,
  256. dispidMSInfoRefresh = 2L,
  257. dispidMSInfoLoadFile = 3L,
  258. dispidMSInfoSelectAll = 4L,
  259. dispidMSInfoCopy = 5L,
  260. dispidMSInfoUpdateView = 6L,
  261. dispidMSInfoGetData = 7L,
  262. //}}AFX_DISP_ID
  263. };
  264. private:
  265. void DrawLine();
  266. BOOL FormatColumns();
  267. BOOL AddColumn(int idsLabel, int nItem, int nSubItem = -1, int size = 0,
  268. int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
  269. int nFmt = LVCFMT_LEFT);
  270. BOOL AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex = -1);
  271. void RefigureColumns(CRect& rect);
  272. void RefreshListControl(BOOL bRedraw);
  273. void RefreshEditControl(BOOL bRedraw);
  274. void DeleteArrayObject(void *ptrArray);
  275. void RefreshArray(int iView, int &iListItem, CPtrArray &ptrarrayNew);
  276. CString GetStringFromIDS(int ids);
  277. CString GetStringFromVariant(COleVariant &var, int idsFormat = 0);
  278. void AddToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszItem, LPCTSTR pszValue);
  279. void AddToArray(CPtrArray &ptrarray, int itemNum, int idsItem, LPCTSTR pszValue);
  280. void AddBlankLineToArray(CPtrArray &ptrarray, int itemNum);
  281. void AddEditBlankLineToArray(CPtrArray &ptrarray, int itemNum);
  282. void AddFileVersionToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszFile, LPCTSTR pszVersion, LPCTSTR pszSize, LPCTSTR pszDate, LPCTSTR pszPath, LPCTSTR pszCompany, DWORD dwSize, DATE date);
  283. void AddEditToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszItem, LPCTSTR pszValue, BOOL bBold = FALSE);
  284. void AddEditToArray(CPtrArray &ptrarray, int itemNum, int idsItem, LPCTSTR pszValue, BOOL bBold = FALSE);
  285. void AddObjectToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszProgramFile, LPCTSTR pszStatus, LPCTSTR pszCodeBase);
  286. void AddCertificateToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszIssuedTo, LPCTSTR pszIssuedBy, LPCTSTR pszValidity, LPCTSTR pszSignatureAlgorithm);
  287. void AddNameToArray(CPtrArray &ptrarray, int itemNum, LPCTSTR pszName);
  288. //====================================================================
  289. // MSInfo Specific...
  290. //
  291. // Add members to the control class to keep track of the currently
  292. // displayed data. In this example, we use a flag to indicate if the
  293. // data is current or loaded from a file.
  294. //====================================================================
  295. CBrush *m_pCtlBkBrush;
  296. bool m_bCurrent;
  297. CListCtrl m_list;
  298. CImageList m_imageList;
  299. CPtrArray m_ptrarray;
  300. CStatic m_static;
  301. CButton m_btnBasic, m_btnAdvanced;
  302. CRichEditCtrl m_edit;
  303. CFont m_fontStatic, m_fontBtn;
  304. UINT m_uiView;
  305. // The following member variables are used to keep track of the
  306. // column sizes on the list control.
  307. int m_cColumns;
  308. int m_aiRequestedWidths[20];
  309. int m_aiColumnWidths[20];
  310. int m_aiMinWidths[20];
  311. int m_aiMaxWidths[20];
  312. // WMI
  313. bool GetIEType(const BSTR classStr, IEDataType &enType);
  314. void ConvertDateToWbemString(COleVariant &var);
  315. void SetIEProperties(IEDataType enType, void *pIEData, IWbemClassObject *pInstance);
  316. IWbemServices *m_pNamespace;
  317. };
  318. #endif // !defined(AFX_MSIECTL_H__25959BFC_E700_11D2_A7AF_00C04F806200__INCLUDED)