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.

99 lines
2.4 KiB

  1. // WMIFilterBrowser.cpp : Implementation of CWMIFilterBrowser
  2. #include "stdafx.h"
  3. #include <wbemidl.h>
  4. #include "resource.h"
  5. #include "defines.h"
  6. #include "ntdmutils.h"
  7. #include "SchemaManager.h"
  8. #include "WMIFilterBrowser.h"
  9. #include "WMIFilterBrowserDlg.h"
  10. extern CWMIFilterBrowserDlg * g_pWMIFilterBrowserDlg;
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CWMIFilterBrowser
  13. CWMIFilterBrowser::CWMIFilterBrowser()
  14. {
  15. }
  16. //--------------------------------------------------------------------------
  17. CWMIFilterBrowser::~CWMIFilterBrowser()
  18. {
  19. }
  20. //---------------------------------------------------------------------------
  21. STDMETHODIMP CWMIFilterBrowser::ConnectToWMI()
  22. {
  23. HRESULT hr;
  24. CComPtr<IWbemLocator>pIWbemLocator;
  25. NTDM_BEGIN_METHOD()
  26. m_pIWbemServices = NULL;
  27. // create the webm locator
  28. NTDM_ERR_MSG_IF_FAIL(CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
  29. IID_IWbemLocator, (LPVOID *) &pIWbemLocator));
  30. NTDM_ERR_MSG_IF_FAIL(pIWbemLocator->ConnectServer( _T("root\\policy"),
  31. NULL,
  32. NULL,
  33. NULL,
  34. 0,
  35. NULL,
  36. NULL,
  37. &m_pIWbemServices));
  38. NTDM_ERR_MSG_IF_FAIL(CoSetProxyBlanket(m_pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
  39. RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE ,
  40. NULL, EOAC_NONE));
  41. NTDM_END_METHOD()
  42. // cleanup
  43. return hr;
  44. }
  45. //--------------------------------------------------------------------------
  46. STDMETHODIMP CWMIFilterBrowser::RunBrowser(HWND hwndParent, VARIANT *vSelection)
  47. {
  48. HRESULT hr;
  49. NTDM_BEGIN_METHOD()
  50. m_hWnd = hwndParent;
  51. NTDM_ERR_IF_FAIL(ConnectToWMI());
  52. g_pWMIFilterBrowserDlg = new CWMIFilterBrowserDlg(this);
  53. if(IDOK == DialogBox(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDD_WMI_FILTER_BROWSER), (HWND)hwndParent, WMIFilterBrowserDlgProc))
  54. {
  55. VariantClear(vSelection);
  56. V_VT(vSelection) = VT_UNKNOWN;
  57. NTDM_ERR_IF_FAIL(g_pWMIFilterBrowserDlg->m_pIWbemClassObject->QueryInterface(IID_IUnknown, (void **)&(V_UNKNOWN(vSelection))));
  58. }
  59. NTDM_END_METHOD()
  60. // cleanup
  61. NTDM_DELETE_OBJECT(g_pWMIFilterBrowserDlg);
  62. return hr;
  63. }
  64. //--------------------------------------------------------------------------
  65. STDMETHODIMP CWMIFilterBrowser::SetMultiSelection(VARIANT_BOOL vbValue)
  66. {
  67. // TODO: Add your implementation code here
  68. return S_OK;
  69. }