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.

789 lines
23 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // CBaseRowObj base class implementation
  7. //
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////////
  10. #include "headers.h"
  11. // NTRaid : 146015
  12. // 07/19/00
  13. QUALIFIERCOLINFO rgQualfierColInfo[] = { {L"QualifierName", DBTYPE_BSTR , -1, 0},
  14. {L"DataType", DBTYPE_UI4 , sizeof(long), 0},
  15. {L"Value", DBTYPE_VARIANT, sizeof(VARIANT), DBCOLUMNFLAGS_WRITE},
  16. {L"Flavor", DBTYPE_UI4, sizeof(long), 0}
  17. };
  18. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  19. // Constructor
  20. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  21. CBaseRowObj::CBaseRowObj(LPUNKNOWN pUnkOuter): CBaseObj(BOT_ROWSET, pUnkOuter)
  22. {
  23. m_pMap = NULL;
  24. m_pRowData = NULL;
  25. m_pChapterMgr = NULL;
  26. m_rgbRowData = NULL;
  27. m_pUtilProp = NULL;
  28. m_pIBuffer = NULL;
  29. m_pIColumnsInfo = NULL;
  30. m_pIConvertType = NULL;
  31. m_pCon = NULL;
  32. m_bNewConAllocated = FALSE;
  33. m_IsZoombie = FALSE;
  34. m_pISupportErrorInfo = NULL;
  35. m_cTotalCols = 0;
  36. m_cCols = 0;
  37. m_cNestedCols = 0;
  38. m_cbRowSize = 0;
  39. m_uRsType = 0;
  40. m_ulProps = 0;
  41. m_hRow = 0;
  42. }
  43. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. // Destructor
  45. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  46. CBaseRowObj::~CBaseRowObj()
  47. {
  48. }
  49. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  50. // Get Column Information
  51. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  52. HRESULT CBaseRowObj::GatherColumnInfo()
  53. {
  54. HRESULT hr = S_OK;
  55. switch( m_uRsType)
  56. {
  57. case SCHEMA_ROWSET:
  58. case METHOD_ROWSET:
  59. case COMMAND_ROWSET:
  60. case 0 :
  61. //=============================================================
  62. // Get the number of columns
  63. //=============================================================
  64. hr = m_pMap->GetColumnInfoForParentColumns(&m_Columns);
  65. break;
  66. case PROPERTYQUALIFIER:
  67. case CLASSQUALIFIER:
  68. //==================================================================================
  69. // Get the number of columns for the property qualifier
  70. //==================================================================================
  71. hr = GatherColumnInfoForQualifierRowset();
  72. break;
  73. default:
  74. hr = E_FAIL;
  75. break;
  76. };
  77. if( hr == S_OK )
  78. {
  79. m_cbRowSize = m_Columns.SetRowSize();
  80. hr = m_Columns.FreeUnusedMemory();
  81. }
  82. return hr;
  83. }
  84. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  85. // Get a value of a Rowset property
  86. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  87. HRESULT CBaseRowObj::GetRowsetProperty(DBPROPID propId , VARIANT & varValue)
  88. {
  89. DBPROPIDSET rgPropertyIDSets[1];
  90. ULONG cPropertySets = 0;
  91. DBPROPSET* prgPropertySets = NULL;
  92. DBPROPID rgPropId[1];
  93. HRESULT hr = S_OK;
  94. VariantClear(&varValue);
  95. //========================================================================
  96. // Get the value of the required rowset property
  97. //========================================================================
  98. rgPropertyIDSets[0].guidPropertySet = DBPROPSET_ROWSET;
  99. rgPropertyIDSets[0].rgPropertyIDs = rgPropId;
  100. rgPropertyIDSets[0].cPropertyIDs = 1;
  101. rgPropId[0] = propId;
  102. if( S_OK == (hr = m_pUtilProp->GetProperties( PROPSET_ROWSET, 1, rgPropertyIDSets,&cPropertySets, &prgPropertySets )))
  103. VariantCopy(&varValue,&prgPropertySets->rgProperties->vValue);
  104. //==========================================================================
  105. // Free memory we allocated to by GetProperties
  106. //==========================================================================
  107. m_pUtilProp->m_PropMemMgr.FreeDBPROPSET( cPropertySets, prgPropertySets);
  108. return hr;
  109. }
  110. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  111. // Get some of the boolean properties of the rowset to set a particular bit in the flag in one of the member variables
  112. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  113. void CBaseRowObj::GetCommonRowsetProperties()
  114. {
  115. VARIANT vPropVal;
  116. VariantInit(&vPropVal);
  117. HRESULT hr = 0;
  118. if(S_OK == GetRowsetProperty(DBPROP_CANHOLDROWS,vPropVal))
  119. {
  120. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  121. {
  122. m_ulProps |= CANHOLDROWS;
  123. VariantClear(&vPropVal);
  124. }
  125. }
  126. if(S_OK == GetRowsetProperty(DBPROP_CANSCROLLBACKWARDS,vPropVal))
  127. {
  128. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  129. {
  130. m_ulProps |= CANSCROLLBACKWARDS;
  131. VariantClear(&vPropVal);
  132. }
  133. }
  134. if(S_OK == GetRowsetProperty(DBPROP_CANFETCHBACKWARDS,vPropVal))
  135. {
  136. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  137. {
  138. m_ulProps |= CANFETCHBACKWARDS;
  139. VariantClear(&vPropVal);
  140. }
  141. }
  142. if(S_OK == GetRowsetProperty(DBPROP_OTHERUPDATEDELETE,vPropVal))
  143. {
  144. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  145. {
  146. m_ulProps |= OTHERUPDATEDELETE;
  147. VariantClear(&vPropVal);
  148. }
  149. }
  150. if(S_OK == GetRowsetProperty(DBPROP_OWNINSERT,vPropVal))
  151. {
  152. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  153. {
  154. m_ulProps |= OWNINSERT;
  155. VariantClear(&vPropVal);
  156. }
  157. }
  158. if(S_OK == GetRowsetProperty(DBPROP_REMOVEDELETED,vPropVal))
  159. {
  160. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  161. {
  162. m_ulProps |= REMOVEDELETED;
  163. VariantClear(&vPropVal);
  164. }
  165. }
  166. if(S_OK == GetRowsetProperty(DBPROP_OTHERINSERT,vPropVal))
  167. {
  168. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  169. {
  170. m_ulProps |= OTHERINSERT;
  171. VariantClear(&vPropVal);
  172. }
  173. }
  174. if(S_OK == GetRowsetProperty(DBPROP_OWNUPDATEDELETE,vPropVal))
  175. {
  176. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  177. {
  178. m_ulProps |= OWNUPDATEDELETE;
  179. VariantClear(&vPropVal);
  180. }
  181. }
  182. if(S_OK == GetRowsetProperty(DBPROP_IRowsetChange,vPropVal))
  183. {
  184. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  185. {
  186. m_ulProps |= IROWSETCHANGE;
  187. VariantClear(&vPropVal);
  188. }
  189. }
  190. if(S_OK == GetRowsetProperty(DBPROP_BOOKMARKS,vPropVal))
  191. {
  192. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  193. {
  194. m_ulProps |= BOOKMARKPROP;
  195. VariantClear(&vPropVal);
  196. }
  197. }
  198. if(S_OK == GetRowsetProperty(DBPROP_WMIOLEDB_FETCHDEEP,vPropVal))
  199. {
  200. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  201. {
  202. m_ulProps |= FETCHDEEP;
  203. VariantClear(&vPropVal);
  204. }
  205. }
  206. if(S_OK == GetRowsetProperty(DBPROP_IRowsetLocate,vPropVal))
  207. {
  208. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  209. {
  210. m_ulProps |= IROWSETLOCATE;
  211. VariantClear(&vPropVal);
  212. }
  213. }
  214. if(S_OK == GetRowsetProperty(DBPROP_IGetRow,vPropVal))
  215. {
  216. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  217. {
  218. m_ulProps |= IGETROW;
  219. VariantClear(&vPropVal);
  220. }
  221. }
  222. if(S_OK == GetRowsetProperty(DBPROP_IRowsetRefresh,vPropVal))
  223. {
  224. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  225. {
  226. m_ulProps |= IROWSETREFRESH;
  227. VariantClear(&vPropVal);
  228. }
  229. }
  230. if(S_OK == GetRowsetProperty(DBPROP_IChapteredRowset,vPropVal))
  231. {
  232. if(V_BOOL(&vPropVal) == VARIANT_TRUE)
  233. {
  234. m_ulProps |= ICHAPTEREDROWSET;
  235. VariantClear(&vPropVal);
  236. }
  237. }
  238. }
  239. //////////////////////////////////////////////////////////////////////////////////////////////////////
  240. // Get the column information
  241. // Get the information about the various properties of the classes if rowset is refering to a class
  242. // Get the information of the the different qualifiers if rowset is referring to qualifiers
  243. //////////////////////////////////////////////////////////////////////////////////////////////////////
  244. HRESULT CBaseRowObj::GetColumnInfo(void)
  245. {
  246. HRESULT hr = S_OK;
  247. //==================================================================================
  248. // switch on type of the recordset. If it is 0 then the recordset is
  249. // representing the instances of the class
  250. //==================================================================================
  251. switch( m_uRsType)
  252. {
  253. case SCHEMA_ROWSET:
  254. case COMMAND_ROWSET:
  255. case METHOD_ROWSET:
  256. case 0 :
  257. //==================================================================================
  258. // Get the count of columns in the table
  259. //==================================================================================
  260. hr = m_pMap->GetColumnCount(m_cTotalCols,m_cCols,m_cNestedCols);
  261. break;
  262. case PROPERTYQUALIFIER :
  263. case CLASSQUALIFIER:
  264. //==================================================================================
  265. // Get the number of columns for the property qualifier
  266. //==================================================================================
  267. m_cCols = NUMBER_OF_COLUMNS_IN_QUALIFERROWSET + 1; // for first column which should be always used
  268. // as bookmark
  269. m_cTotalCols = m_cCols;
  270. break;
  271. default:
  272. hr = E_FAIL;
  273. break;
  274. };
  275. if( SUCCEEDED(hr))
  276. {
  277. // NTRaid : 142133 & 141923
  278. // 07/12/00
  279. if(m_cTotalCols == 0)
  280. {
  281. hr = S_OK;
  282. }
  283. else
  284. {
  285. if( S_OK == (hr = m_Columns.AllocColumnNameList(m_cTotalCols)) ){
  286. //===============================================================================
  287. // Allocate the DBCOLUMNINFO structs to match the number of columns
  288. //===============================================================================
  289. if( S_OK == (hr = m_Columns.AllocColumnInfoList(m_cTotalCols))){
  290. m_Columns.InitializeBookMarkColumn();
  291. hr = GatherColumnInfo();
  292. }
  293. }
  294. }
  295. }
  296. //==================================================================================
  297. // Free the columnlist if more is allocated
  298. //==================================================================================
  299. if( hr != S_OK ){
  300. m_Columns.FreeColumnNameList();
  301. m_Columns.FreeColumnInfoList();
  302. }
  303. return hr;
  304. }
  305. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  306. // Get ordinal of the column given the column name
  307. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  308. DBORDINAL CBaseRowObj::GetOrdinalFromColName(WCHAR *pColName)
  309. {
  310. return m_Columns.GetColOrdinal(pColName);
  311. }
  312. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  313. // Set a particular rowset property
  314. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  315. HRESULT CBaseRowObj::SetRowsetProperty(DBPROPID propId , VARIANT varValue)
  316. {
  317. DBPROPSET rgPropertySets[1];
  318. DBPROP rgprop[1];
  319. HRESULT hr = S_OK;
  320. memset(&rgprop[0],0,sizeof(DBPROP));
  321. memset(&rgPropertySets[0],0,sizeof(DBPROPSET));
  322. rgprop[0].dwPropertyID = propId;
  323. VariantCopy(&rgprop[0].vValue,&varValue);
  324. rgPropertySets[0].rgProperties = &rgprop[0];
  325. rgPropertySets[0].cProperties = 1;
  326. rgPropertySets[0].guidPropertySet = DBPROPSET_ROWSET;
  327. hr = m_pUtilProp->SetProperties( PROPSET_ROWSET,1,rgPropertySets);
  328. VariantClear(&rgprop[0].vValue);
  329. return hr;
  330. }
  331. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  332. // Refresh the instance pointer
  333. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  334. HRESULT CBaseRowObj::RefreshInstance(CWbemClassWrapper *pInstance)
  335. {
  336. return m_pMap->RefreshInstance(pInstance);
  337. }
  338. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  339. // Get the mode property of the Datasource and set the UPDATIBILITY property of the rowset accordingly
  340. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  341. HRESULT CBaseRowObj::SynchronizeDataSourceMode()
  342. {
  343. HRESULT hr = S_OK;
  344. BOOL bUpdate = TRUE;
  345. VARIANT varPropValue;
  346. VariantInit(&varPropValue);
  347. //==================================================
  348. // Get the mode property of the datasource
  349. //==================================================
  350. if(S_OK == (hr = m_pCreator->GetDataSrcProperty(DBPROP_INIT_MODE,varPropValue)))
  351. {
  352. switch(varPropValue.lVal)
  353. {
  354. case DB_MODE_READ:
  355. bUpdate = FALSE;
  356. break;
  357. case DB_MODE_SHARE_DENY_WRITE:
  358. bUpdate = FALSE;
  359. break;
  360. }
  361. }
  362. //===============================================================
  363. // If the datasource is opened in readonly then set the rowset
  364. // property to readonly
  365. //===============================================================
  366. if(bUpdate == FALSE)
  367. {
  368. varPropValue.lVal = 0;
  369. SetRowsetProperty(DBPROP_UPDATABILITY , varPropValue);
  370. }
  371. return hr;
  372. }
  373. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  374. // Get Column information for rowset representing qualifiers
  375. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  376. HRESULT CBaseRowObj::GatherColumnInfoForQualifierRowset()
  377. {
  378. HRESULT hr = S_OK;
  379. m_Columns.ResetColumns();
  380. CDataMap DataMap;
  381. DBCOLUMNINFO **ppColCurColInfo = NULL;
  382. //======================================================================================
  383. // Column information for rowset showing qualifer is constant and is stored in array
  384. // Get this information from this array an put it into the column information mgr
  385. //======================================================================================
  386. for( int nIndex = 0 ; nIndex < NUMBER_OF_COLUMNS_IN_QUALIFERROWSET ; nIndex++)
  387. {
  388. ppColCurColInfo = m_Columns.CurrentColInfo();
  389. hr = m_Columns.AddColumnNameToList(rgQualfierColInfo[nIndex].pwszName, ppColCurColInfo);
  390. if( hr == S_OK )
  391. {
  392. m_pMap->SetCommonDBCOLUMNINFO(ppColCurColInfo, m_Columns.GetCurrentIndex());
  393. (*ppColCurColInfo)->wType = rgQualfierColInfo[nIndex].wType;
  394. (*ppColCurColInfo)->ulColumnSize = rgQualfierColInfo[nIndex].ulSize;
  395. (*ppColCurColInfo)->dwFlags = rgQualfierColInfo[nIndex].dwStatus;
  396. // NTRaid:111762
  397. // 06/13/00
  398. hr = m_Columns.CommitColumnInfo();
  399. }
  400. }
  401. return hr;
  402. }
  403. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  404. // Get the mode property of the Datasource and set the UPDATIBILITY property of the rowset accordingly
  405. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  406. ULONG CBaseRowObj::GetQualifierFlags()
  407. {
  408. HRESULT hr = S_OK;
  409. ULONG lRet = 0;
  410. VARIANT varPropValue;
  411. VariantInit(&varPropValue);
  412. //===============================================================================================
  413. // Get the value of DBPROP_WMIOLEDB_QUALIFIERS property whether to show qualifiers or not
  414. //===============================================================================================
  415. if(S_OK == (hr = m_pCreator->GetDataSrcProperty(DBPROP_WMIOLEDB_QUALIFIERS,varPropValue)))
  416. {
  417. lRet = varPropValue.lVal;
  418. }
  419. return lRet;
  420. }
  421. //////////////////////////////////////////////////////////////////////////////////////////////////////
  422. // Set properties on the object
  423. //////////////////////////////////////////////////////////////////////////////////////////////////////
  424. HRESULT CBaseRowObj::SetProperties(const ULONG cPropertySets, const DBPROPSET rgPropertySets[] )
  425. {
  426. HRESULT hr = S_OK;
  427. VARIANT varPropVal;
  428. VariantInit(&varPropVal);
  429. LONG lFlag = 0;
  430. //============================================================================
  431. //Set rowset properties
  432. //============================================================================
  433. if ( cPropertySets > 0 )
  434. {
  435. DBPROPSET* pPropSets = (DBPROPSET*)rgPropertySets;
  436. //=====================================================
  437. // Check the arguments
  438. //=====================================================
  439. if( S_OK == (hr = m_pUtilProp->SetPropertiesArgChk(cPropertySets, pPropSets)))
  440. {
  441. hr = m_pUtilProp->SetProperties(PROPSET_ROWSET, cPropertySets, pPropSets);
  442. if( (hr == DB_E_ERRORSOCCURRED) || (hr == DB_S_ERRORSOCCURRED) )
  443. {
  444. //====================================================================
  445. // If all the properties set were OPTIONAL then we can set
  446. // our status to DB_S_ERRORSOCCURRED and continue.
  447. //====================================================================
  448. for(ULONG ul=0;ul<cPropertySets; ul++)
  449. {
  450. for(ULONG ul2=0;ul2<rgPropertySets[ul].cProperties; ul2++)
  451. {
  452. //============================================================
  453. // Check for a required property that failed, if found, we
  454. // must return DB_E_ERRORSOCCURRED
  455. //============================================================
  456. if( (rgPropertySets[ul].rgProperties[ul2].dwStatus != DBPROPSTATUS_NOTSETTABLE) &&
  457. (rgPropertySets[ul].rgProperties[ul2].dwStatus != DBPROPSTATUS_OK) &&
  458. (rgPropertySets[ul].rgProperties[ul2].dwOptions != DBPROPOPTIONS_OPTIONAL) )
  459. {
  460. hr = DB_E_ERRORSOCCURRED ;
  461. break;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. }
  468. //============================================================================
  469. // call this function to set the DBPROP_UPDATIBILITY to readonly if the Datasource
  470. // open mode is readonly
  471. //============================================================================
  472. if( (hr == S_OK) || (hr == DB_S_ERRORSOCCURRED) )
  473. {
  474. SynchronizeDataSourceMode();
  475. hr = S_OK;
  476. }
  477. return hr;
  478. }
  479. //////////////////////////////////////////////////////////////////////////////////////////////////////
  480. // Set Search preference
  481. //////////////////////////////////////////////////////////////////////////////////////////////////////
  482. HRESULT CBaseRowObj::SetSearchPreferences()
  483. {
  484. HRESULT hr = S_OK;
  485. DBPROPIDSET rgPropertyIDSets[1];
  486. ULONG cPropertySets;
  487. DBPROPSET* prgPropertySets;
  488. DBPROPID rgPropId[NUMBEROF_SEARCHPREF];
  489. rgPropId[0] = DBPROP_WMIOLEDB_DS_DEREFALIAS;
  490. rgPropId[1] = DBPROP_WMIOLEDB_DS_SIZELIMIT;
  491. rgPropId[2] = DBPROP_WMIOLEDB_DS_PAGEDTIMELIMIT;
  492. rgPropId[3] = DBPROP_WMIOLEDB_DS_ASYNCH;
  493. rgPropId[4] = DBPROP_WMIOLEDB_DS_SEARCHSCOPE;
  494. rgPropId[5] = DBPROP_WMIOLEDB_DS_TIMEOUT;
  495. rgPropId[6] = DBPROP_WMIOLEDB_DS_PAGESIZE;
  496. rgPropId[7] = DBPROP_WMIOLEDB_DS_TIMELIMIT;
  497. rgPropId[8] = DBPROP_WMIOLEDB_DS_CHASEREF;
  498. rgPropId[9] = DBPROP_WMIOLEDB_DS_FILTER;
  499. rgPropId[10] = DBPROP_WMIOLEDB_DS_CACHERESULTS;
  500. rgPropId[11] = DBPROP_WMIOLEDB_DS_ATTRIBUTES;
  501. rgPropId[12] = DBPROP_WMIOLEDB_DS_TOMBSTONE;
  502. rgPropId[13] = DBPROP_WMIOLEDB_DS_ATTRIBONLY;
  503. rgPropertyIDSets[0].guidPropertySet = DBPROPSET_ROWSET;
  504. rgPropertyIDSets[0].rgPropertyIDs = rgPropId;
  505. rgPropertyIDSets[0].cPropertyIDs = NUMBEROF_SEARCHPREF;
  506. //==============================================================================
  507. // Get the value of the DBPROP_INIT_DATASOURCE property, this is the namespace
  508. // to be opened.
  509. //==============================================================================
  510. hr = m_pUtilProp->GetProperties( PROPSET_ROWSET,1, rgPropertyIDSets,&cPropertySets,&prgPropertySets );
  511. if( SUCCEEDED(hr) )
  512. {
  513. hr = m_pMap->SetSearchPreferences(prgPropertySets->cProperties,prgPropertySets[0].rgProperties);
  514. //==========================================================================
  515. // Free memory we allocated to get the namespace property above
  516. //==========================================================================
  517. m_pUtilProp->m_PropMemMgr.FreeDBPROPSET( cPropertySets, prgPropertySets);
  518. }
  519. return hr;
  520. }
  521. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  522. // Function to get a DBPROP_WMIOLEDB_OBJECTTYPE property .
  523. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  524. INSTANCELISTTYPE CBaseRowObj::GetObjectTypeProp(const ULONG cPropertySets, const DBPROPSET rgPropertySets[])
  525. {
  526. INSTANCELISTTYPE instType = SCOPE;
  527. BOOL bFound = FALSE;
  528. for( ULONG lIndex = 0 ; lIndex < cPropertySets ; lIndex++)
  529. {
  530. if(rgPropertySets[lIndex].guidPropertySet == DBPROPSET_ROWSET ||
  531. rgPropertySets[lIndex].guidPropertySet == DBPROPSET_WMIOLEDB_ROWSET )
  532. {
  533. for ( ULONG nPropIndex = 0 ; nPropIndex < rgPropertySets[lIndex].cProperties ; nPropIndex++ )
  534. {
  535. if(rgPropertySets[lIndex].rgProperties[nPropIndex].dwPropertyID == DBPROP_WMIOLEDB_OBJECTTYPE)
  536. {
  537. instType = rgPropertySets[lIndex].rgProperties[nPropIndex].vValue.lVal == DBPROPVAL_SCOPEOBJ ? SCOPE : CONTAINER;
  538. bFound = TRUE;
  539. break;
  540. } // if DBPROP_IRow is true;
  541. }// for loop
  542. } // if propertyset is DBPROPSET_ROWSET or DBPROPSET_WMIOLEDB_ROWSET
  543. if(bFound)
  544. {
  545. break;
  546. }
  547. } // outer for loop
  548. return instType;
  549. }
  550. // set rowset properties for Schema rowset
  551. HRESULT CBaseRowObj::InitializePropertiesForSchemaRowset()
  552. {
  553. HRESULT hr = S_OK;
  554. LONG lIndex = 0;
  555. DBPROPSET rgPropertySets[1];
  556. DBPROP rgprop[5];
  557. memset(&rgprop[0],0,sizeof(DBPROP) * 5);
  558. memset(&rgPropertySets[0],0,sizeof(DBPROPSET));
  559. rgprop[0].dwPropertyID = DBPROP_UPDATABILITY;
  560. rgprop[1].dwPropertyID = DBPROP_IRowsetChange;
  561. rgprop[2].dwPropertyID = DBPROP_IRowsetLocate;
  562. rgprop[3].dwPropertyID = DBPROP_BOOKMARKS;
  563. rgprop[4].dwPropertyID = DBPROP_IGetRow;
  564. rgprop[0].vValue.vt = VT_I4;
  565. rgprop[0].vValue.lVal = 0;
  566. for(lIndex = 1 ; lIndex < 5 ; lIndex++)
  567. {
  568. rgprop[lIndex].vValue.vt = VT_BOOL;
  569. rgprop[lIndex].vValue.boolVal = VARIANT_FALSE;
  570. }
  571. rgPropertySets[0].rgProperties = &rgprop[0];
  572. rgPropertySets[0].cProperties = 5;
  573. rgPropertySets[0].guidPropertySet = DBPROPSET_ROWSET;
  574. hr = m_pUtilProp->SetProperties( PROPSET_ROWSET,1,rgPropertySets);
  575. return hr;
  576. }
  577. // set rowset properties for command rowset
  578. HRESULT CBaseRowObj::InitializePropertiesForCommandRowset()
  579. {
  580. HRESULT hr = S_OK;
  581. LONG lIndex = 0;
  582. DBPROPSET rgPropertySets[1];
  583. DBPROP rgprop[2];
  584. memset(&rgprop[0],0,sizeof(DBPROP) * 2);
  585. memset(&rgPropertySets[0],0,sizeof(DBPROPSET));
  586. rgprop[0].dwPropertyID = DBPROP_IRowsetLocate;
  587. rgprop[1].dwPropertyID = DBPROP_BOOKMARKS;
  588. for(lIndex = 0 ; lIndex < 2 ; lIndex++)
  589. {
  590. rgprop[lIndex].vValue.vt = VT_BOOL;
  591. rgprop[lIndex].vValue.boolVal = VARIANT_FALSE;
  592. }
  593. rgPropertySets[0].rgProperties = &rgprop[0];
  594. rgPropertySets[0].cProperties = 2;
  595. rgPropertySets[0].guidPropertySet = DBPROPSET_ROWSET;
  596. hr = m_pUtilProp->SetProperties( PROPSET_ROWSET,1,rgPropertySets);
  597. return hr;
  598. }
  599. // set rowset properties for method rowset
  600. HRESULT CBaseRowObj::InitializePropertiesForMethodRowset()
  601. {
  602. HRESULT hr = S_OK;
  603. LONG lIndex = 0;
  604. DBPROPSET rgPropertySets[1];
  605. DBPROP rgprop[5];
  606. memset(&rgprop[0],0,sizeof(DBPROP) * 5);
  607. memset(&rgPropertySets[0],0,sizeof(DBPROPSET));
  608. rgprop[0].dwPropertyID = DBPROP_UPDATABILITY;
  609. rgprop[1].dwPropertyID = DBPROP_IRowsetChange;
  610. rgprop[2].dwPropertyID = DBPROP_IRowsetLocate;
  611. rgprop[3].dwPropertyID = DBPROP_BOOKMARKS;
  612. rgprop[4].dwPropertyID = DBPROP_IGetRow;
  613. rgprop[0].vValue.vt = VT_I4;
  614. rgprop[0].vValue.lVal = 0;
  615. for(lIndex = 1 ; lIndex < 5 ; lIndex++)
  616. {
  617. rgprop[lIndex].vValue.vt = VT_BOOL;
  618. rgprop[lIndex].vValue.boolVal = VARIANT_FALSE;
  619. }
  620. rgPropertySets[0].rgProperties = &rgprop[0];
  621. rgPropertySets[0].cProperties = 5;
  622. rgPropertySets[0].guidPropertySet = DBPROPSET_ROWSET;
  623. hr = m_pUtilProp->SetProperties( PROPSET_ROWSET,1,rgPropertySets);
  624. return hr;
  625. }