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.

126 lines
3.7 KiB

  1. /* Dispatch.cpp
  2. *
  3. * History: a-jsari 3/18/98 Initial version.
  4. *
  5. * Copyright (c) 1998-1999 Microsoft Corporation
  6. */
  7. #include "StdAfx.h"
  8. #include "Dispatch.h"
  9. #include "DataSrc.h"
  10. /*
  11. * CMSInfo -
  12. *
  13. * History: a-jsari 3/18/98 Initial version.
  14. */
  15. CMSInfo::CMSInfo()
  16. {
  17. }
  18. /*
  19. * ~CMSInfo - Vacuous destructor
  20. *
  21. * History: a-jsari 3/18/98 Initial version.
  22. */
  23. CMSInfo::~CMSInfo()
  24. {
  25. }
  26. /*
  27. * make_nfo - Create an NFO file from a connection to the specified computer.
  28. *
  29. * History: a-jsari 3/18/98 Initial version.
  30. */
  31. STDMETHODIMP CMSInfo::make_nfo(BSTR lpszFilename, BSTR lpszComputername)
  32. {
  33. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  34. ASSERT(lpszFilename != NULL);
  35. if (lpszFilename == NULL) return E_INVALIDARG;
  36. CDataSource *pDataSource = new CWBEMDataSource(lpszComputername);
  37. if (pDataSource == NULL) return E_ACCESSDENIED;
  38. return pDataSource->SaveFile(lpszFilename);
  39. }
  40. /*
  41. * make_report - Create a text report from a connection to the specified computer.
  42. *
  43. * History: a-jsari 3/18/98 Initial version.
  44. */
  45. STDMETHODIMP CMSInfo::make_report(BSTR lpszFilename, BSTR lpszComputername, BSTR lpszCategory)
  46. {
  47. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  48. ASSERT(lpszFilename != NULL);
  49. if (lpszFilename == NULL) return E_INVALIDARG;
  50. CDataSource *pDataSource = new CWBEMDataSource(lpszComputername);
  51. if (pDataSource == NULL) return E_ACCESSDENIED;
  52. CFolder *pFolder;
  53. if (lpszCategory == NULL) pFolder = NULL;
  54. else {
  55. ASSERT(FALSE);
  56. }
  57. return pDataSource->ReportWrite(lpszFilename, pFolder);
  58. }
  59. //-----------------------------------------------------------------------------
  60. // This function is exposed through COM to create an NFO file, for the
  61. // specified computer, with the specified categories. It should not be
  62. // assumed that there will be any UI during this operation.
  63. //-----------------------------------------------------------------------------
  64. STDMETHODIMP CMSInfo::MakeNFO(BSTR lpszFilename, BSTR lpszComputername, BSTR lpszCategory)
  65. {
  66. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  67. CString strFilename(lpszFilename);
  68. CString strComputer(lpszComputername);
  69. CString strCategory(lpszCategory);
  70. CDataSource * pDataSource = new CWBEMDataSource(strComputer);
  71. if (pDataSource == NULL)
  72. return E_ACCESSDENIED;
  73. if (pDataSource->SetCategories(strCategory) == FALSE)
  74. return E_ACCESSDENIED;
  75. HRESULT hr = pDataSource->SaveFile(strFilename);
  76. delete pDataSource;
  77. return (hr);
  78. }
  79. //-----------------------------------------------------------------------------
  80. // This function is exposed through COM to create a report file, for the
  81. // specified computer, with the specified categories. It should not be
  82. // assumed that there will be any UI during this operation.
  83. //-----------------------------------------------------------------------------
  84. STDMETHODIMP CMSInfo::MakeReport(BSTR lpszFilename, BSTR lpszComputername, BSTR lpszCategory)
  85. {
  86. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  87. CString strFilename(lpszFilename);
  88. CString strComputer(lpszComputername);
  89. CString strCategory(lpszCategory);
  90. CDataSource * pDataSource = new CWBEMDataSource(strComputer);
  91. if (pDataSource == NULL)
  92. return E_ACCESSDENIED;
  93. if (pDataSource->SetCategories(strCategory) == FALSE)
  94. return E_ACCESSDENIED;
  95. HRESULT hr = pDataSource->ReportWrite(strFilename, NULL);
  96. delete pDataSource;
  97. return (hr);
  98. }
  99. //-----------------------------------------------------------------------------
  100. // This function is exposed through COM to return a list of categories with
  101. // the UI labels matched to internal names (for use when specifying categories
  102. // to display or save).
  103. //-----------------------------------------------------------------------------
  104. STDMETHODIMP CMSInfo::QueryCategories(BSTR lpszCategories)
  105. {
  106. // Not implemented yet.
  107. return S_OK;
  108. }