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.

665 lines
19 KiB

  1. // DPGenericPage.cpp : implementation file
  2. //
  3. // 03/05/00 v-marfin bug 59643 : Make this the default starting page.
  4. // 03/27/00 v-marfin bug 62317 : Require user to select at least 1 property before saving
  5. // 03/27/00 v-marfin bug 60014 : Ensure instance exists before letting user save value.
  6. // 03/29/00 v-marfin bug 62585 : Set new Data collector's ENABLED to TRUE if user presses OK.
  7. // 03/30/00 v-marfin bug 59237 : If user does not change the default name of the data
  8. // collector when they first create it, change it for
  9. // them to a more meaningful name based on the data
  10. // they select in the property pages.
  11. //
  12. #include "stdafx.h"
  13. #include "snapin.h"
  14. #include "DPGenericPage.h"
  15. #include "HMObject.h"
  16. #include "HMDataElementConfiguration.h"
  17. #include "WmiBrowseDlg.h"
  18. #include "WmiPropertyBrowseDlg.h"
  19. #include "DataElement.h"
  20. #include "DataGroupScopeItem.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CDPWmiInstancePage property page
  28. // static array
  29. IMPLEMENT_DYNCREATE(CDPWmiInstancePage, CHMPropertyPage)
  30. CDPWmiInstancePage::CDPWmiInstancePage() : CHMPropertyPage(CDPWmiInstancePage::IDD)
  31. {
  32. //{{AFX_DATA_INIT(CDPWmiInstancePage)
  33. m_bManualReset = FALSE;
  34. m_sClass = _T("");
  35. m_sInstance = _T("");
  36. m_sNamespace = _T("");
  37. //}}AFX_DATA_INIT
  38. m_sHelpTopic = _T("HMon21.chm::/dDEinst.htm");
  39. }
  40. CDPWmiInstancePage::~CDPWmiInstancePage()
  41. {
  42. }
  43. void CDPWmiInstancePage::UpdateProperties()
  44. {
  45. m_Properties.DeleteAllItems();
  46. if( m_sClass.IsEmpty() )
  47. {
  48. return;
  49. }
  50. CWbemClassObject classobject;
  51. classobject.SetNamespace(_T("\\\\") + GetObjectPtr()->GetSystemName() + _T("\\") + m_sNamespace);
  52. HRESULT hr = classobject.GetObject(m_sClass);
  53. if( hr != S_OK )
  54. {
  55. return;
  56. }
  57. CStringArray saNames;
  58. classobject.GetPropertyNames(saNames);
  59. classobject.Destroy();
  60. for( int i = 0; i < saNames.GetSize(); i++ )
  61. {
  62. m_Properties.InsertItem(0,saNames[i]);
  63. }
  64. m_Properties.SetColumnWidth(0,LVSCW_AUTOSIZE);
  65. }
  66. void CDPWmiInstancePage::DoDataExchange(CDataExchange* pDX)
  67. {
  68. CHMPropertyPage::DoDataExchange(pDX);
  69. //{{AFX_DATA_MAP(CDPWmiInstancePage)
  70. DDX_Control(pDX, IDC_LIST_PROPERTIES, m_Properties);
  71. DDX_Check(pDX, IDC_CHECK_MANUAL_RESET, m_bManualReset);
  72. DDX_Text(pDX, IDC_EDIT_CLASS, m_sClass);
  73. DDX_Text(pDX, IDC_EDIT_INSTANCE, m_sInstance);
  74. DDX_Text(pDX, IDC_EDIT_NAMESPACE, m_sNamespace);
  75. //}}AFX_DATA_MAP
  76. }
  77. BEGIN_MESSAGE_MAP(CDPWmiInstancePage, CHMPropertyPage)
  78. //{{AFX_MSG_MAP(CDPWmiInstancePage)
  79. ON_BN_CLICKED(IDC_CHECK_MANUAL_RESET, OnCheckManualReset)
  80. ON_BN_CLICKED(IDC_BUTTON_BROWSE_NAMESPACE, OnButtonBrowseNamespace)
  81. ON_BN_CLICKED(IDC_BUTTON_BROWSE_CLASS, OnButtonBrowseClass)
  82. ON_BN_CLICKED(IDC_BUTTON_BROWSE_INSTANCE, OnButtonBrowseInstance)
  83. ON_EN_CHANGE(IDC_EDIT_NAMESPACE, OnChangeEditNamespace)
  84. ON_EN_CHANGE(IDC_EDIT_CLASS, OnChangeEditClass)
  85. ON_EN_CHANGE(IDC_EDIT_INSTANCE, OnChangeEditInstance)
  86. ON_NOTIFY(NM_CLICK, IDC_LIST_PROPERTIES, OnClickListProperties)
  87. ON_WM_DESTROY()
  88. //}}AFX_MSG_MAP
  89. END_MESSAGE_MAP()
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CDPWmiInstancePage message handlers
  92. BOOL CDPWmiInstancePage::OnInitDialog()
  93. {
  94. // v-marfin : bug 59643 : This will be the default starting page for the property
  95. // sheet so call CnxPropertyPageCreate() to unmarshal the
  96. // connection for this thread. This function must be called
  97. // by the first page of the property sheet. It used to
  98. // be called by the "General" page and its call still remains
  99. // there as well in case the general page is loaded by a
  100. // different code path that does not also load this page.
  101. // The CnxPropertyPageCreate function has been safeguarded
  102. // to simply return if the required call has already been made.
  103. // CnxPropertyPageDestory() must be called from this page's
  104. // OnDestroy function.
  105. // unmarshal connmgr
  106. CnxPropertyPageCreate();
  107. CHMPropertyPage::OnInitDialog();
  108. // initialize the list view
  109. m_Properties.SetExtendedStyle(LVS_EX_CHECKBOXES);
  110. CString sColumnTitle;
  111. sColumnTitle.LoadString(IDS_STRING_NAME);
  112. m_Properties.InsertColumn(0,sColumnTitle);
  113. //-------------------------------------------------------------------------
  114. CWbemClassObject* pClassObject = GetObjectPtr()->GetClassObject();
  115. if( ! GfxCheckObjPtr(pClassObject,CWbemClassObject) )
  116. {
  117. return TRUE;
  118. }
  119. // v-marfin 59237 : Store original name in case this data collector is
  120. // just being created. When they save, we will modify the
  121. // name if they haven't.
  122. pClassObject->GetProperty(IDS_STRING_MOF_NAME,m_sOriginalName);
  123. delete pClassObject;
  124. //-------------------------------------------------------------------------
  125. CString sObjectPath = GetObjectPtr()->GetObjectPath();
  126. CHMPolledGetObjectDataElementConfiguration pgodec;
  127. pgodec.Create(GetObjectPtr()->GetSystemName());
  128. pgodec.GetObject(GetObjectPtr()->GetObjectPath());
  129. pgodec.GetAllProperties();
  130. m_sNamespace = pgodec.m_sTargetNamespace;
  131. m_sClass = pgodec.m_sObjectPath;
  132. int iIndex = -1;
  133. if( (iIndex = m_sClass.Find(_T("."))) != -1 )
  134. {
  135. m_sInstance = m_sClass;
  136. m_sClass = m_sClass.Left(iIndex);
  137. }
  138. m_bManualReset = pgodec.m_bRequireManualReset;
  139. UpdateProperties();
  140. for( int i=0; i < pgodec.m_saStatisticsPropertyNames.GetSize(); i++ )
  141. {
  142. LVFINDINFO lvfi;
  143. ZeroMemory(&lvfi,sizeof(LVFINDINFO));
  144. lvfi.flags = LVFI_WRAP|LVFI_STRING;
  145. lvfi.psz = pgodec.m_saStatisticsPropertyNames[i];
  146. int iListIndex = m_Properties.FindItem(&lvfi);
  147. if( iListIndex >= 0 )
  148. {
  149. m_Properties.SetCheck(iListIndex);
  150. }
  151. }
  152. UpdateData(FALSE);
  153. return TRUE; // return TRUE unless you set the focus to a control
  154. // EXCEPTION: OCX Property Pages should return FALSE
  155. }
  156. void CDPWmiInstancePage::OnCheckManualReset()
  157. {
  158. UpdateData();
  159. SetModified();
  160. }
  161. void CDPWmiInstancePage::OnOK()
  162. {
  163. CHMPropertyPage::OnOK();
  164. }
  165. void CDPWmiInstancePage::OnButtonBrowseNamespace()
  166. {
  167. CWmiNamespaceBrowseDlg dlg;
  168. // set the dialog window title
  169. CString sItem;
  170. sItem.LoadString(IDS_STRING_NAMESPACES);
  171. dlg.m_sDlgTitle.Format(IDS_STRING_WMI_BROWSE_TITLE,sItem,GetObjectPtr()->GetSystemName());
  172. // create the namespace enumerator
  173. if( ! CHECKHRESULT(dlg.m_ClassObject.Create(GetObjectPtr()->GetSystemName())) )
  174. {
  175. return;
  176. }
  177. if( m_sNamespace.IsEmpty() )
  178. {
  179. m_sNamespace.Format(IDS_STRING_MOF_NAMESPACE_FORMAT,GetObjectPtr()->GetSystemName());
  180. }
  181. dlg.m_sTitle.Format(_T("\\\\%s\\%s"),GetObjectPtr()->GetSystemName(),m_sNamespace);
  182. dlg.m_ClassObject.SetNamespace(dlg.m_sTitle);
  183. // set the listbox title
  184. dlg.m_sTitle = m_sNamespace;
  185. // display dialog
  186. if( dlg.DoModal() == IDOK )
  187. {
  188. m_sNamespace = dlg.m_sSelectedItem;
  189. m_sClass.Empty();
  190. m_sInstance.Empty();
  191. UpdateData(FALSE);
  192. UpdateProperties();
  193. SetModified();
  194. }
  195. }
  196. void CDPWmiInstancePage::OnButtonBrowseClass()
  197. {
  198. //-----------------------------------------------------------------------------
  199. // v-marfin : 60754 : Validate namespace before attempting to browse for class.
  200. UpdateData();
  201. CSnapInApp* pApp = (CSnapInApp*)AfxGetApp();
  202. if ((pApp) && (!pApp->ValidNamespace(m_sNamespace,GetObjectPtr()->GetSystemName())))
  203. {
  204. AfxMessageBox(IDS_ERR_INVALID_NAMESPACE);
  205. GetDlgItem(IDC_EDIT_NAMESPACE)->SetFocus();
  206. return;
  207. }
  208. //------------------------------------------------------------------------------
  209. CWmiClassBrowseDlg dlg;
  210. // set the dialog window title
  211. CString sItem;
  212. sItem.LoadString(IDS_STRING_CLASSES);
  213. dlg.m_sDlgTitle.Format(IDS_STRING_WMI_BROWSE_TITLE,sItem,GetObjectPtr()->GetSystemName());
  214. // create the class enumerator
  215. if( ! CHECKHRESULT(dlg.m_ClassObject.Create(GetObjectPtr()->GetSystemName())) )
  216. {
  217. return;
  218. }
  219. CString sTemp;
  220. sTemp.Format(_T("\\\\%s\\%s"),GetObjectPtr()->GetSystemName(),m_sNamespace);
  221. dlg.m_ClassObject.SetNamespace(sTemp);
  222. if( ! CHECKHRESULT(dlg.m_ClassObject.CreateClassEnumerator(NULL)) )
  223. {
  224. return;
  225. }
  226. // set the listbox title
  227. dlg.m_sTitle = m_sNamespace;
  228. // display the dialog
  229. if( dlg.DoModal() == IDOK )
  230. {
  231. m_sClass = dlg.m_sSelectedItem;
  232. m_sInstance.Empty();
  233. UpdateData(FALSE);
  234. UpdateProperties();
  235. SetModified();
  236. }
  237. }
  238. void CDPWmiInstancePage::OnButtonBrowseInstance()
  239. {
  240. //----------------------------------------------------------
  241. // v-marfin 60014 : Ensure the class exists before attempting to read for instance
  242. UpdateData();
  243. m_sClass.TrimRight();
  244. m_sClass.TrimLeft();
  245. if (m_sClass.IsEmpty())
  246. {
  247. AfxMessageBox(IDS_ERR_CLASS_REQUIRED_FOR_INSTANCE);
  248. GetDlgItem(IDC_EDIT_CLASS)->SetFocus();
  249. return;
  250. }
  251. //----------------------------------------------------------
  252. //----------------------------------------
  253. // v-marfin 60754 : Validate the namespace
  254. CSnapInApp* pApp = (CSnapInApp*)AfxGetApp();
  255. if ((pApp) && (!pApp->ValidNamespace(m_sNamespace,GetObjectPtr()->GetSystemName())))
  256. {
  257. AfxMessageBox(IDS_ERR_INVALID_NAMESPACE);
  258. GetDlgItem(IDC_EDIT_NAMESPACE)->SetFocus();
  259. return;
  260. }
  261. //-----------------------------------------
  262. CWmiInstanceBrowseDlg dlg;
  263. // set the dialog window title
  264. CString sItem;
  265. sItem.LoadString(IDS_STRING_INSTANCES);
  266. dlg.m_sDlgTitle.Format(IDS_STRING_WMI_BROWSE_TITLE,sItem,GetObjectPtr()->GetSystemName());
  267. // create the instance enumerator
  268. if( ! CHECKHRESULT(dlg.m_ClassObject.Create(GetObjectPtr()->GetSystemName())) )
  269. {
  270. return;
  271. }
  272. CString sTemp;
  273. sTemp.Format(_T("\\\\%s\\%s"),GetObjectPtr()->GetSystemName(),m_sNamespace);
  274. dlg.m_ClassObject.SetNamespace(sTemp);
  275. BSTR bsTemp = m_sClass.AllocSysString();
  276. if( ! CHECKHRESULT(dlg.m_ClassObject.CreateEnumerator(bsTemp)) )
  277. {
  278. ::SysFreeString(bsTemp);
  279. return;
  280. }
  281. ::SysFreeString(bsTemp);
  282. // set the listbox title
  283. dlg.m_sTitle = m_sNamespace;
  284. // display the dialog
  285. if( dlg.DoModal() == IDOK )
  286. {
  287. m_sInstance = dlg.m_sSelectedItem;
  288. UpdateData(FALSE);
  289. SetModified();
  290. }
  291. }
  292. void CDPWmiInstancePage::OnChangeEditNamespace()
  293. {
  294. // TODO: If this is a RICHEDIT control, the control will not
  295. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  296. // function and call CRichEditCtrl().SetEventMask()
  297. // with the ENM_CHANGE flag ORed into the mask.
  298. if( m_sNamespace.Find(_T("\\\\")) != -1 )
  299. {
  300. AfxMessageBox(IDS_STRING_NO_REMOTE_NAMESPACES);
  301. GetDlgItem(IDC_EDIT_NAMESPACE)->SetWindowText(_T(""));
  302. }
  303. GetDlgItem(IDC_EDIT_CLASS)->SetWindowText(_T(""));
  304. GetDlgItem(IDC_EDIT_INSTANCE)->SetWindowText(_T(""));
  305. UpdateData();
  306. UpdateProperties();
  307. SetModified();
  308. }
  309. void CDPWmiInstancePage::OnChangeEditClass()
  310. {
  311. // TODO: If this is a RICHEDIT control, the control will not
  312. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  313. // function and call CRichEditCtrl().SetEventMask()
  314. // with the ENM_CHANGE flag ORed into the mask.
  315. GetDlgItem(IDC_EDIT_INSTANCE)->SetWindowText(_T(""));
  316. UpdateData();
  317. UpdateProperties();
  318. SetModified();
  319. }
  320. void CDPWmiInstancePage::OnChangeEditInstance()
  321. {
  322. // TODO: If this is a RICHEDIT control, the control will not
  323. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  324. // function and call CRichEditCtrl().SetEventMask()
  325. // with the ENM_CHANGE flag ORed into the mask.
  326. // 60014b------------------------------------------------------------------
  327. m_sClass.TrimLeft();
  328. m_sInstance.TrimLeft();
  329. int i = 0;
  330. for (LPCTSTR p = (LPCTSTR)m_sInstance; *p; p++, i++)
  331. {
  332. if (iswspace(*p))
  333. continue;
  334. if (!iswalnum(*p) || *p == _T('_'))
  335. {
  336. // if this, the first non-alphanum character, is
  337. // a ".", then the string before us is the class name. If
  338. // the current class name does not match this, fill it in
  339. // automatically.
  340. if (*p == _T('.'))
  341. {
  342. CString strClass(m_sInstance, i); // first "i" chars
  343. if (strClass != m_sClass)
  344. {
  345. GetDlgItem (IDC_EDIT_CLASS)->SetWindowText(strClass);
  346. UpdateData();
  347. }
  348. }
  349. // since we've reached the end of the first "word", we know
  350. // that the class name can't be here. leave the loop
  351. break;
  352. }
  353. }
  354. //-------------------------------------------------------------------------
  355. UpdateData();
  356. SetModified();
  357. }
  358. BOOL CDPWmiInstancePage::OnApply()
  359. {
  360. if( ! CHMPropertyPage::OnApply() )
  361. {
  362. return FALSE;
  363. }
  364. // v-marfin 62585 : So we can set the collector's state to enabled when OK pressed.
  365. m_bOnApplyUsed=TRUE;
  366. //------------------------------------------------------------------
  367. // v-marfin 60014 : Ensure the instance specified exists if specified
  368. UpdateData();
  369. m_sClass.TrimRight();
  370. m_sClass.TrimLeft();
  371. if (m_sClass.IsEmpty())
  372. {
  373. // 60014b : Changed msgbox to MB_OKCANCEL
  374. AfxMessageBox(IDS_ERR_CLASS_REQUIRED);
  375. GetDlgItem(IDC_EDIT_CLASS)->SetFocus();
  376. return FALSE;
  377. }
  378. // Class must exist
  379. if (!ObjectExists(m_sClass))
  380. {
  381. // 60014b : Changed msgbox to MB_OKCANCEL
  382. AfxMessageBox(IDS_ERR_CLASS_REQUIRED);
  383. GetDlgItem(IDC_EDIT_CLASS)->SetFocus();
  384. return FALSE;
  385. }
  386. m_sInstance.TrimRight();
  387. m_sInstance.TrimLeft();
  388. BOOL bInstanceExists=TRUE;
  389. if (!m_sInstance.IsEmpty())
  390. {
  391. if (!ObjectExists(m_sInstance))
  392. {
  393. // 60014b : Changed msgbox to MB_OKCANCEL
  394. if (AfxMessageBox(IDS_ERR_INSTANCE_NOT_EXISTS,MB_OKCANCEL) == IDCANCEL)
  395. {
  396. GetDlgItem(IDC_EDIT_INSTANCE)->SetFocus();
  397. return FALSE;
  398. }
  399. bInstanceExists=FALSE;
  400. }
  401. }
  402. //------------------------------------------------------------------
  403. CStringArray saProperties;
  404. for( int i = 0; i < m_Properties.GetItemCount(); i++ )
  405. {
  406. if( m_Properties.GetCheck(i) )
  407. {
  408. saProperties.Add(m_Properties.GetItemText(i,0));
  409. }
  410. }
  411. // 62317b Only present err if there were any properties to begin with.
  412. if ((saProperties.GetSize()==0) && (m_Properties.GetItemCount()>0) )
  413. {
  414. // v-marfin 62317 : Add err msg so user knows what is going on.
  415. AfxMessageBox(IDS_ERR_MUST_SELECT_ATLEAST_ONE_PROPERTY);
  416. return FALSE;
  417. }
  418. CString sObjectPath = GetObjectPtr()->GetObjectPath();
  419. CHMPolledGetObjectDataElementConfiguration pgodec;
  420. pgodec.Create(GetObjectPtr()->GetSystemName());
  421. pgodec.GetObject(GetObjectPtr()->GetObjectPath());
  422. pgodec.GetAllProperties();
  423. pgodec.m_saStatisticsPropertyNames.RemoveAll();
  424. pgodec.m_sTargetNamespace = m_sNamespace;
  425. if ((m_sInstance.IsEmpty()) || (!bInstanceExists))
  426. {
  427. pgodec.m_sObjectPath = m_sClass;
  428. }
  429. else
  430. {
  431. pgodec.m_sObjectPath = m_sInstance;
  432. }
  433. pgodec.m_saStatisticsPropertyNames.Copy(saProperties);
  434. pgodec.SaveAllProperties();
  435. SetModified(FALSE);
  436. return TRUE;
  437. }
  438. void CDPWmiInstancePage::OnClickListProperties(NMHDR* pNMHDR, LRESULT* pResult)
  439. {
  440. SetModified();
  441. *pResult = 0;
  442. }
  443. void CDPWmiInstancePage::OnDestroy()
  444. {
  445. // v-marfin 62585 : For this new data collector, set its Enabled property to TRUE, but
  446. // only if the user is not cancelling these property pages.
  447. if (m_bOnApplyUsed)
  448. {
  449. ClearStatistics(); // 62548
  450. CDataElement* pElement = (CDataElement*)GetObjectPtr();
  451. if (pElement && pElement->IsStateSetToEnabledOnOK())
  452. {
  453. TRACE(_T("CDPWmiInstancePage::OnDestroy - New Perfmon Collector: Setting to Enabled\n"));
  454. pElement->SetStateToEnabledOnOK(FALSE); // don't do this again
  455. CWbemClassObject* pClassObject = GetObjectPtr()->GetClassObject();
  456. if( ! GfxCheckObjPtr(pClassObject,CWbemClassObject) )
  457. {
  458. TRACE(_T("ERROR: CDPWmiInstancePage::OnDestroy - Failed to GetClassObject()\n"));
  459. return;
  460. }
  461. // Set the new collector to enabled.
  462. BOOL bEnabled=TRUE;
  463. HRESULT hr = pClassObject->GetProperty(IDS_STRING_MOF_ENABLE,bEnabled);
  464. hr = pClassObject->SetProperty(IDS_STRING_MOF_ENABLE,TRUE);
  465. if (!CHECKHRESULT(hr))
  466. {
  467. TRACE(_T("ERROR: CDPWmiInstancePage::OnDestroy - Failed to set ENABLED property on new collector\n"));
  468. }
  469. //-------------------------------------------------------------------
  470. // v-marfin 59237 : If the user has not changed the original default
  471. // name, do so for them. Compare against original
  472. // name we fetched during OnInitDialog.
  473. CString sName;
  474. pClassObject->GetProperty(IDS_STRING_MOF_NAME,sName);
  475. // Did the user change the default name?
  476. if (m_sOriginalName.CompareNoCase(sName)==0)
  477. {
  478. // 62981 : set new name to instance, or class if instance is empty
  479. CString sObject = m_sInstance.IsEmpty() ? m_sClass : m_sInstance;
  480. // No, so set the new name
  481. if (!sObject.IsEmpty())
  482. {
  483. // Use parent to ensure name is unique
  484. //CDataGroup* pParent = (CDataGroup*) pElement->GetCollectorsParentClassObject();
  485. if(pElement->GetScopeItemCount())
  486. {
  487. CDataElementScopeItem* pItem = (CDataElementScopeItem*)pElement->GetScopeItem(0);
  488. if( pItem )
  489. {
  490. CDataGroupScopeItem* pDGItem = (CDataGroupScopeItem*)pItem->GetParent();
  491. sName = pDGItem->GetUniqueDisplayName(sObject);
  492. }
  493. }
  494. // Set the local element's object data
  495. pElement->SetName(sName);
  496. // Set its WMI property
  497. pClassObject->SetProperty(IDS_STRING_MOF_NAME,sName);
  498. // Refresh to show the new name in the IU
  499. //pElement->Refresh(); // 63005
  500. pElement->UpdateStatus(); // 63005
  501. }
  502. }
  503. //-------------------------------------------------------------------
  504. pClassObject->SaveAllProperties();
  505. delete pClassObject;
  506. } // if (pElement && pElement->IsStateSetToEnabledOnOK())
  507. } // if (m_bOnApplyUsed)
  508. CHMPropertyPage::OnDestroy();
  509. // v-marfin : bug 59643 : CnxPropertyPageDestory() must be called from this page's
  510. // OnDestroy function.
  511. CnxPropertyPageDestroy();
  512. }
  513. // v-marfin : 60014
  514. //******************************************************************
  515. // InstanceExists
  516. //******************************************************************
  517. BOOL CDPWmiInstancePage::ObjectExists(const CString &refObjectPath)
  518. {
  519. CString sNamespace;
  520. if (refObjectPath.IsEmpty())
  521. return FALSE;
  522. ULONG ulReturned = 0L;
  523. int i = 0;
  524. CWbemClassObject* pClassObject = new CWbemClassObject;
  525. if (!pClassObject)
  526. return TRUE;
  527. pClassObject->SetNamespace(_T("\\\\") + GetObjectPtr()->GetSystemName() + _T("\\") + m_sNamespace);
  528. HRESULT hr = pClassObject->GetObject(refObjectPath);
  529. delete pClassObject;
  530. return (hr == S_OK);
  531. }