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.

757 lines
22 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // CBinder object implementation
  7. //
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////////
  10. #include "headers.h"
  11. #include "WmiOleDBMap.h"
  12. ///////////////////////////////////////////////////////////////////////////////////
  13. // Constructor
  14. ///////////////////////////////////////////////////////////////////////////////////
  15. CBinder::CBinder(LPUNKNOWN pUnkOuter) : CBaseObj(BOT_BINDER,pUnkOuter)
  16. {
  17. m_cRef = 0;
  18. m_pICreateRow = NULL;
  19. m_pIBinderProperties = NULL;
  20. m_pIBindResource = NULL;
  21. m_pISupportErrorInfo = NULL;
  22. m_pDataSrc = NULL;
  23. m_pSession = NULL;
  24. m_pUrlParser = NULL;
  25. m_fDSOInitialized = FALSE;
  26. //===============================================================
  27. // Increment global object count.
  28. //===============================================================
  29. InterlockedIncrement(&g_cObj);
  30. }
  31. ///////////////////////////////////////////////////////////////////////////////////
  32. // Destructor
  33. ///////////////////////////////////////////////////////////////////////////////////
  34. CBinder::~CBinder()
  35. {
  36. HRESULT hr = S_OK;
  37. IDBInitialize *pInitialize = NULL;
  38. SAFE_RELEASE_PTR(m_pSession);
  39. SAFE_RELEASE_PTR(m_pDataSrc);
  40. SAFE_DELETE_PTR(m_pICreateRow);
  41. SAFE_DELETE_PTR(m_pIBinderProperties);
  42. SAFE_DELETE_PTR(m_pIBindResource);
  43. SAFE_DELETE_PTR(m_pISupportErrorInfo);
  44. SAFE_DELETE_PTR(m_pUrlParser);
  45. SAFE_DELETE_PTR(m_pUtilProp);
  46. //===============================================================
  47. // Decrement global object count.
  48. //===============================================================
  49. InterlockedDecrement(&g_cObj);
  50. }
  51. /////////////////////////////////////////////////////////////////////////////////////////////////
  52. // Function to navigate between the different interfaces
  53. /////////////////////////////////////////////////////////////////////////////////////////////////
  54. STDMETHODIMP CBinder::QueryInterface ( REFIID riid, LPVOID * ppv)
  55. {
  56. HRESULT hr = S_OK;
  57. //======================================================
  58. // Check parameters, if not valid return
  59. //======================================================
  60. if (NULL == ppv){
  61. hr = E_INVALIDARG ;
  62. }
  63. else
  64. {
  65. //======================================================
  66. // Place NULL in *ppv in case of failure
  67. //======================================================
  68. *ppv = NULL;
  69. //======================================================
  70. // This is the non-delegating IUnknown implementation
  71. //======================================================
  72. if (riid == IID_IUnknown)
  73. {
  74. *ppv = (LPVOID) this;
  75. }
  76. else if (riid == IID_IBindResource)
  77. {
  78. *ppv = (LPVOID) m_pIBindResource;
  79. }
  80. else if (riid == IID_IDBBinderProperties || riid == IID_IDBProperties)
  81. {
  82. *ppv = (LPVOID) m_pIBinderProperties;
  83. }
  84. else if (riid == IID_ICreateRow)
  85. {
  86. *ppv = (LPVOID) m_pICreateRow;
  87. }
  88. else if(riid == IID_ISupportErrorInfo)
  89. {
  90. *ppv = (LPVOID)m_pISupportErrorInfo;
  91. }
  92. //======================================================
  93. // If we're going to return an interface, AddRef first
  94. //======================================================
  95. if (*ppv){
  96. ((LPUNKNOWN) *ppv)->AddRef();
  97. hr = S_OK ;
  98. }
  99. else{
  100. hr = E_NOINTERFACE;
  101. }
  102. }
  103. return hr;
  104. }
  105. /////////////////////////////////////////////////////////////////////////////////////////////////
  106. //
  107. // Increments a persistence count for the object
  108. //
  109. // Current reference count
  110. //
  111. /////////////////////////////////////////////////////////////////////////////////////////////////
  112. STDMETHODIMP_( ULONG ) CBinder::AddRef( void )
  113. {
  114. return InterlockedIncrement((long*)&m_cRef);
  115. }
  116. /////////////////////////////////////////////////////////////////////////////////////////////////
  117. //
  118. // Decrements a persistence count for the object and if persistence count is 0, the object
  119. // destroys itself.
  120. //
  121. /////////////////////////////////////////////////////////////////////////////////////////////////
  122. STDMETHODIMP_( ULONG ) CBinder::Release( void )
  123. {
  124. InterlockedDecrement((long*)&m_cRef);
  125. if (!m_cRef){
  126. g_pIDataConvert->Release();
  127. delete this;
  128. return 0;
  129. }
  130. return m_cRef;
  131. }
  132. /////////////////////////////////////////////////////////////////////////////////////////////////
  133. // Function to initialize the binder object
  134. /////////////////////////////////////////////////////////////////////////////////////////////////
  135. HRESULT CBinder::InitBinder()
  136. {
  137. HRESULT hr = S_OK;
  138. BOOL bRet = TRUE;
  139. //================================================
  140. // Instantiate the data conversion service object
  141. //================================================
  142. if( !g_pIDataConvert ){
  143. hr = CoCreateInstance(CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, IID_IDataConvert, (void **)&g_pIDataConvert);
  144. }
  145. else
  146. {
  147. //============================================
  148. // Already instantiated, increment reference
  149. // count
  150. //============================================
  151. g_pIDataConvert->AddRef();
  152. }
  153. if(SUCCEEDED(hr))
  154. {
  155. IDCInfo *pDcInfo = NULL;
  156. DCINFO dcInfo[1];
  157. dcInfo[0].eInfoType = DCINFOTYPE_VERSION;
  158. V_VT(&dcInfo[0].vData) = VT_UI4;
  159. V_UI4(&dcInfo[0].vData) = 0x200;
  160. hr = g_pIDataConvert->QueryInterface(IID_IDCInfo,(void **)&pDcInfo);
  161. hr = pDcInfo->SetInfo(1,dcInfo);
  162. //================================================
  163. // Allocate properties management object
  164. //================================================
  165. m_pUtilProp = new CUtilProp;
  166. if(m_pUtilProp == NULL)
  167. {
  168. hr = E_OUTOFMEMORY;
  169. }
  170. else
  171. // NTRaid: 136443
  172. // 07/05/00
  173. if(SUCCEEDED(hr = m_pUtilProp->FInit(BINDERPROP)))
  174. {
  175. //================================================
  176. // Allocate the URLParser class
  177. //================================================
  178. m_pUrlParser = new CURLParser;
  179. //================================================
  180. // Allocate contained interface objects
  181. //================================================
  182. m_pIBindResource = new CImplIBindResource( this );
  183. m_pICreateRow = new CImplICreateRow( this );
  184. m_pIBinderProperties = new CImplIDBBinderProperties( this );
  185. m_pISupportErrorInfo = new CImpISupportErrorInfo(this);
  186. if(!((BOOL)(m_pUtilProp && m_pUrlParser && m_pIBindResource && m_pICreateRow && m_pIBinderProperties && m_pISupportErrorInfo)))
  187. {
  188. hr = E_OUTOFMEMORY;
  189. }
  190. }
  191. }
  192. if(SUCCEEDED(hr))
  193. {
  194. hr = AddInterfacesForISupportErrorInfo();
  195. }
  196. return hr;
  197. }
  198. /////////////////////////////////////////////////////////////////////////////////////////////////////
  199. // Function to add interfaces to ISupportErrorInfo interface
  200. /////////////////////////////////////////////////////////////////////////////////////////////////////
  201. HRESULT CBinder::AddInterfacesForISupportErrorInfo()
  202. {
  203. HRESULT hr = S_OK;
  204. if(SUCCEEDED(hr = m_pISupportErrorInfo->AddInterfaceID(IID_IBindResource)))
  205. if(SUCCEEDED(hr = m_pISupportErrorInfo->AddInterfaceID(IID_IDBBinderProperties)))
  206. if(SUCCEEDED(hr = m_pISupportErrorInfo->AddInterfaceID(IID_IDBProperties)))
  207. {
  208. hr = m_pISupportErrorInfo->AddInterfaceID(IID_ICreateRow);
  209. }
  210. return hr;
  211. }
  212. /////////////////////////////////////////////////////////////////////////////////////////////////
  213. // Function to Create a Datasource object. The init flat parameter is the flags obtained
  214. // from the binder flags passed to the IBinderResource::Bind function
  215. // If the caller needs a pointer to a particular interface , then the id of the interface
  216. // required will be passed in riid parmeter , otherwise this parameter will be GUID_NULL
  217. /////////////////////////////////////////////////////////////////////////////////////////////////
  218. HRESULT CBinder::CreateDSO(IUnknown *pUnkOuter,LONG lInitFlag, REFGUID riid,IUnknown ** ppUnk)
  219. {
  220. HRESULT hr = E_FAIL;
  221. IDBInitialize * pInitialize = NULL;
  222. IDBProperties * pDBProperties = NULL;
  223. DBPROPSET rgPropertySets[1];
  224. DBPROPIDSET rgPropIDSet[1];
  225. DBPROP rgprop[1];
  226. VARIANT varValue;
  227. ULONG cPropSets = 1;
  228. DBPROPSET* prgPropertySets;
  229. DBPROPID rgPropId[1];
  230. if(m_pDataSrc != NULL)
  231. {
  232. hr = S_OK;
  233. if( riid != GUID_NULL)
  234. {
  235. //=============================================
  236. // Get the required interface pointer
  237. //=============================================
  238. hr = m_pDataSrc->QueryInterface(riid , (void **)ppUnk);
  239. }
  240. }
  241. else
  242. {
  243. memset(&rgprop[0],0,sizeof(DBPROP));
  244. memset(&rgPropertySets[0],0,sizeof(DBPROPSET));
  245. VariantInit(&varValue);
  246. CDataSource *pDatasource = NULL;
  247. try
  248. {
  249. //=============================================
  250. // Allocate a new datasource object
  251. //=============================================
  252. pDatasource = new CDataSource( pUnkOuter );
  253. }
  254. catch(...)
  255. {
  256. SAFE_DELETE_PTR(pDatasource);
  257. throw;
  258. }
  259. if(pDatasource == NULL)
  260. {
  261. hr = E_OUTOFMEMORY;
  262. }
  263. else
  264. if(SUCCEEDED(hr = pDatasource->FInit()))
  265. {
  266. //==================================================================
  267. // QI for IUnknown and save pointer in the member variable
  268. //==================================================================
  269. if(SUCCEEDED(hr =pDatasource->QueryInterface(IID_IUnknown , (void **)&m_pDataSrc)))
  270. if(SUCCEEDED(hr = m_pDataSrc->QueryInterface(IID_IDBProperties ,(void **)&pDBProperties)))
  271. {
  272. rgPropIDSet[0].cPropertyIDs = 0;
  273. rgPropIDSet[0].guidPropertySet = DBPROPSET_DBINIT;
  274. //==================================================================
  275. // Get the properties set thru IDBBinderProperties
  276. //==================================================================
  277. hr = m_pUtilProp->GetProperties(PROPSET_INIT,0,rgPropIDSet, &cPropSets,&prgPropertySets);
  278. if(SUCCEEDED(hr = pDBProperties->SetProperties(cPropSets,prgPropertySets)))
  279. {
  280. //==========================================================================
  281. // Free memory we allocated to by GetProperties
  282. //==========================================================================
  283. m_pUtilProp->m_PropMemMgr.FreeDBPROPSET( cPropSets, prgPropertySets);
  284. rgPropId[0] = DBPROP_INIT_DATASOURCE;
  285. rgPropIDSet[0].guidPropertySet = DBPROPSET_DBINIT;
  286. rgPropIDSet[0].rgPropertyIDs = rgPropId;
  287. rgPropIDSet[0].cPropertyIDs = 1;
  288. hr = m_pUtilProp->GetProperties( PROPSET_INIT,1, rgPropIDSet,&cPropSets,&prgPropertySets );
  289. if(SUCCEEDED(hr))
  290. {
  291. // if the property set is not empty then get the property DBPROP_INIT_DATASOURCE
  292. // else extract it from URL
  293. if(prgPropertySets[0].rgProperties[0].vValue.vt == VT_BSTR &&
  294. prgPropertySets[0].rgProperties[0].vValue.bstrVal != NULL &&
  295. SysStringLen(prgPropertySets[0].rgProperties[0].vValue.bstrVal) > 0)
  296. {
  297. rgprop[0].vValue.bstrVal = Wmioledb_SysAllocString(prgPropertySets[0].rgProperties[0].vValue.bstrVal);
  298. }
  299. else
  300. {
  301. m_pUrlParser->GetNameSpace(rgprop[0].vValue.bstrVal);
  302. }
  303. //==========================================================================
  304. // Free memory we allocated to by GetProperties
  305. //==========================================================================
  306. m_pUtilProp->m_PropMemMgr.FreeDBPROPSET( cPropSets, prgPropertySets);
  307. //==================================================================
  308. // Get the namespace from the Parser and then set
  309. // the DBPROP_INIT_DATASOURCE property
  310. //==================================================================
  311. rgprop[0].dwPropertyID = DBPROP_INIT_DATASOURCE;
  312. rgprop[0].vValue.vt = VT_BSTR;
  313. // m_pUrlParser->GetNameSpace(rgprop[0].vValue.bstrVal);
  314. rgPropertySets[0].rgProperties = &rgprop[0];
  315. rgPropertySets[0].cProperties = 1;
  316. rgPropertySets[0].guidPropertySet = DBPROPSET_DBINIT;
  317. if(SUCCEEDED(hr = pDBProperties->SetProperties(1,rgPropertySets)))
  318. {
  319. // set the properties on the current property handler
  320. hr = m_pUtilProp->SetProperties(PROPSET_INIT,1,rgPropertySets);
  321. }
  322. SAFE_FREE_SYSSTRING(rgprop[0].vValue.bstrVal);
  323. }
  324. if(SUCCEEDED(hr))
  325. {
  326. VariantClear(&(rgprop[0].vValue));
  327. //========================================
  328. // Setting the DBPROP_DBINIT property
  329. //========================================
  330. rgprop[0].dwPropertyID = DBPROP_INIT_MODE;
  331. rgprop[0].vValue.vt =VT_I4;
  332. rgprop[0].vValue.lVal = lInitFlag;
  333. rgPropertySets[0].rgProperties = &rgprop[0];
  334. rgPropertySets[0].cProperties = 1;
  335. rgPropertySets[0].guidPropertySet = DBPROPSET_DBINIT;
  336. if(SUCCEEDED(hr = pDBProperties->SetProperties(1,rgPropertySets)) &&
  337. SUCCEEDED(hr = m_pUtilProp->SetProperties(PROPSET_INIT,1,rgPropertySets)))
  338. {
  339. //===============================================
  340. // Get the pointer to IDBInitialize interface
  341. //===============================================
  342. hr = m_pDataSrc->QueryInterface(IID_IDBInitialize, (void **)&pInitialize);
  343. //===============================================================
  344. // Initialize the Datasource object if
  345. // the flag does not indicate waiting for the initialization
  346. //===============================================================
  347. if(!(lInitFlag & DBBINDURLFLAG_WAITFORINIT))
  348. {
  349. if(S_OK == (hr = pInitialize->Initialize()))
  350. m_fDSOInitialized = TRUE;
  351. }
  352. if(S_OK == hr)
  353. {
  354. if( riid != GUID_NULL)
  355. {
  356. //========================================
  357. // Get the required interface pointer
  358. //========================================
  359. hr = m_pDataSrc->QueryInterface(riid , (void **)ppUnk);
  360. }
  361. }
  362. pInitialize->Release();
  363. pDBProperties->Release();
  364. } // If(Succeeded(call to SetProperties)) of DBPROP_INIT_MODE property
  365. } // If(Succeeded(call to SetProperties)) of DBPROP_INIT_DATASOURCE property
  366. } // If(Succeeded(call to SetProperties))
  367. } // If Succeeded() for QI
  368. } // if(Succeeded(pDatasource->FInit()))
  369. else
  370. {
  371. hr = E_FAIL;
  372. }
  373. } // Else for if(m_pDataSrc != NULL)
  374. return hr;
  375. }
  376. /////////////////////////////////////////////////////////////////////////////////////////////////
  377. // Function to create a session object
  378. /////////////////////////////////////////////////////////////////////////////////////////////////
  379. HRESULT CBinder::CreateSession(IUnknown *pUnkOuter, REFGUID riid,IUnknown ** ppUnk)
  380. {
  381. HRESULT hr = S_OK;
  382. IDBCreateSession * pDBCreateSession = NULL;
  383. IDBInitialize * pInitialize = NULL;
  384. assert(m_pDataSrc != NULL);
  385. //====================================================================
  386. // If the datasource is not yet initialized , then initialize it
  387. //====================================================================
  388. if(m_fDSOInitialized == FALSE)
  389. {
  390. //================================================
  391. // Get the pointer to IDBInitialize interface
  392. //================================================
  393. hr = m_pDataSrc->QueryInterface(IID_IDBInitialize, (void **)&pInitialize);
  394. if(S_OK == (hr = pInitialize->Initialize()))
  395. {
  396. m_fDSOInitialized = TRUE;
  397. }
  398. pInitialize->Release();
  399. }
  400. if(SUCCEEDED(hr))
  401. if(S_OK ==(hr = m_pDataSrc->QueryInterface(IID_IDBCreateSession,(void **)&pDBCreateSession)))
  402. {
  403. //======================
  404. // Create session
  405. //======================
  406. if(S_OK ==(hr = pDBCreateSession->CreateSession(pUnkOuter,IID_IUnknown,(IUnknown**)&m_pSession)))
  407. {
  408. if(riid != GUID_NULL)
  409. {
  410. hr = m_pSession->QueryInterface(riid,(void **)ppUnk);
  411. }
  412. }
  413. }
  414. if(pDBCreateSession)
  415. {
  416. pDBCreateSession->Release();
  417. }
  418. return hr;
  419. }
  420. /////////////////////////////////////////////////////////////////////////////////////////////////
  421. // Function to create a Command object
  422. /////////////////////////////////////////////////////////////////////////////////////////////////
  423. HRESULT CBinder::CreateCommand(IUnknown *pUnkOuter, REFGUID guidTemp,IUnknown ** ppUnk)
  424. {
  425. return m_pSession->CreateCommand(pUnkOuter, guidTemp,ppUnk);
  426. }
  427. /////////////////////////////////////////////////////////////////////////////////////////////////
  428. // Function to create a required row object
  429. // NTRaid:136539 , 136540
  430. // 07/05/00
  431. /////////////////////////////////////////////////////////////////////////////////////////////////
  432. HRESULT CBinder::CreateRow(IUnknown *pUnkOuter, REFGUID riid,IUnknown ** ppUnk ,ROWCREATEBINDFLAG rowCreateFlag)
  433. {
  434. HRESULT hr = E_FAIL;
  435. IUnknown * pUnkRow = NULL;
  436. BSTR strTable = NULL;
  437. BSTR strPath = NULL;
  438. CDBSession * pDBSess = NULL;
  439. ISessionProperties *pSessProp = NULL;
  440. CRow * pNewRow = NULL;
  441. DBPROPSET * pPropSet = NULL;
  442. if( S_OK == (hr = m_pSession->QueryInterface(IID_ISessionProperties , (void **)&pSessProp)))
  443. {
  444. pDBSess = ((CImpISessionProperties *)pSessProp)->GetSessionPtr();
  445. pSessProp->Release();
  446. // Get the path of the object
  447. hr = m_pUrlParser->GetPathWithEmbededInstInfo(strPath);
  448. // Get the class name
  449. // m_pUrlParser->GetClassName(strTable);
  450. // NTRaid : 134967
  451. // 07/12/00
  452. if(SUCCEEDED(hr) && SUCCEEDED(hr = m_pUtilProp->GetConnectionInitProperties(&pPropSet)))
  453. {
  454. hr = GetClassName(m_pUrlParser,pPropSet,strTable,m_pDataSrc->m_pWbemWrap);
  455. }
  456. //==========================================================================
  457. // Free memory we allocated to get the namespace property above
  458. //==========================================================================
  459. CPropertyMemoryMgr::FreeDBPROPSET( 1, pPropSet);
  460. if(SUCCEEDED(hr))
  461. {
  462. try
  463. {
  464. // currently hardcoded to NO_QUALIFIERS
  465. pNewRow = new CRow(pUnkOuter,pDBSess);
  466. }
  467. catch(...)
  468. {
  469. SAFE_DELETE_PTR(pNewRow);
  470. throw;
  471. }
  472. if( pNewRow == NULL)
  473. {
  474. hr = E_OUTOFMEMORY;
  475. }
  476. else
  477. {
  478. if(S_OK ==(hr = pNewRow->InitRow(strPath,strTable,-1,rowCreateFlag)))
  479. {
  480. hr = pNewRow->QueryInterface(riid,(void **)ppUnk);
  481. }
  482. if(hr == S_OK && rowCreateFlag != ROWOPEN)
  483. {
  484. hr = pNewRow->UpdateKeysForNewInstance();
  485. }
  486. }
  487. //========================================================
  488. // Free the strings allocated by the URLParser class
  489. //========================================================
  490. SysFreeString(strTable);
  491. SysFreeString(strPath);
  492. }
  493. if(FAILED(hr))
  494. {
  495. SAFE_DELETE_PTR(pNewRow);
  496. *ppUnk = NULL;
  497. }
  498. }
  499. return hr;
  500. }
  501. /////////////////////////////////////////////////////////////////////////////////////////////////
  502. // Function to create a Rowset object
  503. /////////////////////////////////////////////////////////////////////////////////////////////////
  504. HRESULT CBinder::CreateRowset(IUnknown *pUnkOuter, REFGUID riid,IUnknown ** ppUnk)
  505. {
  506. HRESULT hr = E_FAIL;
  507. IOpenRowset * pOpenRowset = NULL;
  508. DBPROPSET * pPropSet = NULL;
  509. ULONG cPropSets = 1;
  510. DBPROPSET* prgPropertySets = NULL;
  511. BSTR strTableName = NULL;
  512. assert(m_pSession != NULL);
  513. //=========================================
  514. // Get pointer to IOpenRowset interface
  515. //=========================================
  516. if(S_OK == (hr = m_pSession->QueryInterface(IID_IOpenRowset , (void **)&pOpenRowset)))
  517. {
  518. DBPROPIDSET rgPropIDSet[1];
  519. rgPropIDSet[0].cPropertyIDs = 0;
  520. rgPropIDSet[0].guidPropertySet = DBPROPSET_ROWSET;
  521. //=========================================
  522. // Get the properties
  523. //=========================================
  524. hr = m_pUtilProp->GetProperties(PROPSET_ROWSET,0,rgPropIDSet, &cPropSets,&prgPropertySets);
  525. //=========================================
  526. // Get the class name and initialize the tableID
  527. //=========================================
  528. // NTRaid : 134967
  529. // 07/12/00
  530. if(SUCCEEDED(hr))
  531. {
  532. if (SUCCEEDED(hr = m_pUtilProp->GetConnectionInitProperties(&pPropSet)))
  533. {
  534. hr = GetClassName(m_pUrlParser,pPropSet,strTableName,m_pDataSrc->m_pWbemWrap);
  535. if (SUCCEEDED(hr))
  536. {
  537. DBID tableID;
  538. memset(&tableID , 0 , sizeof(DBID));
  539. tableID.eKind = DBKIND_NAME;
  540. tableID.uName.pwszName = strTableName;
  541. //=========================================
  542. // Open the rowset
  543. //=========================================
  544. hr = pOpenRowset->OpenRowset(pUnkOuter,&tableID,NULL,riid,cPropSets,prgPropertySets,ppUnk);
  545. SAFE_FREE_SYSSTRING(strTableName);
  546. }
  547. //==========================================================================
  548. // Free memory we allocated to get the namespace property above
  549. //==========================================================================
  550. CPropertyMemoryMgr::FreeDBPROPSET( 1, pPropSet);
  551. }
  552. //==========================================================================
  553. // Free memory we allocated to by GetProperties
  554. //==========================================================================
  555. m_pUtilProp->m_PropMemMgr.FreeDBPROPSET( cPropSets, prgPropertySets);
  556. }
  557. }
  558. SAFE_RELEASE_PTR(pOpenRowset);
  559. return hr;
  560. }
  561. /*
  562. ///////////////////////////////////////////////////////////////////////////////////////////////////
  563. // Get Binding flags and put it in a variable as INIT_MODE flags
  564. ///////////////////////////////////////////////////////////////////////////////////////////////////
  565. void CBinder::GetInitAndBindFlagsFromBindFlags(DBBINDURLFLAG dwBindURLFlags,LONG & lInitMode ,LONG & lInitBindFlags)
  566. {
  567. lInitMode = 0;
  568. lInitBindFlags = 0;
  569. // DBPROP_INIT_MODE
  570. if(DBBINDURLFLAG_READ & dwBindURLFlags)
  571. {
  572. lInitMode = lInitMode | DB_MODE_READ;
  573. }
  574. if(DBBINDURLFLAG_WRITE & dwBindURLFlags)
  575. {
  576. lInitMode = lInitMode | DB_MODE_WRITE;
  577. }
  578. if(DBBINDURLFLAG_SHARE_DENY_READ & dwBindURLFlags)
  579. {
  580. lInitMode = lInitMode | DB_MODE_SHARE_DENY_READ;
  581. }
  582. if(DBBINDURLFLAG_SHARE_DENY_WRITE & dwBindURLFlags)
  583. {
  584. lInitMode = lInitMode | DB_MODE_SHARE_DENY_WRITE;
  585. }
  586. if(DBBINDURLFLAG_SHARE_EXCLUSIVE & dwBindURLFlags)
  587. {
  588. lInitMode = lInitMode | DB_MODE_SHARE_EXCLUSIVE;
  589. }
  590. if(DBBINDURLFLAG_SHARE_DENY_NONE & dwBindURLFlags)
  591. {
  592. lInitMode = lInitMode | DB_MODE_SHARE_DENY_NONE;
  593. }
  594. // DBPROP_INIT_BINDFLAGS
  595. if(DBBINDURLFLAG_RECURSIVE & dwBindURLFlags)
  596. {
  597. lInitBindFlags = lInitBindFlags | DB_BINDFLAGS_RECURSIVE;
  598. }
  599. if(DBBINDURLFLAG_OUTPUT & dwBindURLFlags)
  600. {
  601. lInitBindFlags = lInitBindFlags | DB_BINDFLAGS_OUTPUT;
  602. }
  603. if(DBBINDURLFLAG_DELAYFETCHCOLUMNS & dwBindURLFlags)
  604. {
  605. lInitBindFlags = lInitBindFlags | DB_BINDFLAGS_DELAYFETCHCOLUMNS;
  606. }
  607. if(DBBINDURLFLAG_DELAYFETCHSTREAM & dwBindURLFlags)
  608. {
  609. lInitBindFlags = lInitBindFlags | DB_BINDFLAGS_DELAYFETCHSTREAM;
  610. }
  611. }
  612. */
  613. ////////////////////////////////////////////////////////////
  614. // Function to release all the bound objects
  615. ////////////////////////////////////////////////////////////
  616. HRESULT CBinder::ReleaseAllObjects()
  617. {
  618. SAFE_RELEASE_PTR(m_pDataSrc);
  619. SAFE_RELEASE_PTR(m_pSession);
  620. return S_OK;
  621. }