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.

135 lines
2.7 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. // ClassDlg.cpp : implementation file
  8. //
  9. #include "stdafx.h"
  10. #include "WMITest.h"
  11. #include "ClassDlg.h"
  12. #include "WMITestDoc.h"
  13. #include "OpView.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CClassDlg dialog
  21. CClassDlg::CClassDlg(CWnd* pParent /*=NULL*/) :
  22. CDialog(CClassDlg::IDD, pParent),
  23. m_pNamespace(NULL)
  24. {
  25. //{{AFX_DATA_INIT(CClassDlg)
  26. // NOTE: the ClassWizard will add member initialization here
  27. //}}AFX_DATA_INIT
  28. }
  29. void CClassDlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CClassDlg)
  33. DDX_Control(pDX, IDC_CLASSES, m_ctlClasses);
  34. //}}AFX_DATA_MAP
  35. }
  36. BEGIN_MESSAGE_MAP(CClassDlg, CDialog)
  37. //{{AFX_MSG_MAP(CClassDlg)
  38. ON_LBN_SELCHANGE(IDC_CLASSES, OnSelchangeClasses)
  39. ON_LBN_DBLCLK(IDC_CLASSES, OnDblclkClasses)
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CClassDlg message handlers
  44. void CClassDlg::LoadList()
  45. {
  46. CWaitCursor wait;
  47. IEnumWbemClassObject *pEnum = NULL;
  48. HRESULT hr =
  49. m_pNamespace->CreateClassEnum(
  50. NULL,
  51. WBEM_FLAG_DEEP | WBEM_FLAG_RETURN_IMMEDIATELY |
  52. WBEM_FLAG_FORWARD_ONLY,
  53. NULL,
  54. &pEnum);
  55. if (SUCCEEDED(hr))
  56. {
  57. IWbemClassObject *pObj = NULL;
  58. DWORD nCount;
  59. g_pOpView->GetDocument()->SetInterfaceSecurity(pEnum);
  60. while(SUCCEEDED(hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &nCount)) &&
  61. nCount > 0)
  62. {
  63. CString strClass;
  64. _variant_t var;
  65. if (SUCCEEDED(pObj->Get(L"__CLASS", 0, &var, NULL, NULL)))
  66. {
  67. if (var.vt == VT_BSTR)
  68. {
  69. strClass = var.bstrVal;
  70. m_ctlClasses.AddString(strClass);
  71. }
  72. pObj->Release();
  73. }
  74. }
  75. pEnum->Release();
  76. }
  77. OnSelchangeClasses();
  78. }
  79. void CClassDlg::OnOK()
  80. {
  81. int iItem = m_ctlClasses.GetCurSel();
  82. if (iItem != -1)
  83. m_ctlClasses.GetText(iItem, m_strClass);
  84. CDialog::OnOK();
  85. }
  86. void CClassDlg::OnSelchangeClasses()
  87. {
  88. GetDlgItem(IDOK)->EnableWindow(m_ctlClasses.GetCurSel() != -1);
  89. }
  90. BOOL CClassDlg::OnInitDialog()
  91. {
  92. CDialog::OnInitDialog();
  93. LoadList();
  94. return TRUE; // return TRUE unless you set the focus to a control
  95. // EXCEPTION: OCX Property Pages should return FALSE
  96. }
  97. void CClassDlg::OnDblclkClasses()
  98. {
  99. OnOK();
  100. }