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.

618 lines
31 KiB

  1. /*****************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. .PCH_NetworkAdapter.CPP
  5. Abstract:
  6. WBEM provider class implementation for PCH_NetworkAdapter class.
  7. 1. This class gets the foll. properties from Win32_NetworkAdapter Class:
  8. AdapterType, DeviceID, ProductName
  9. 2. Gets the foll. properties from Win32_NetworkAdapterConfiguration Class:
  10. ServiceName,IPAddress,IPSubnet,DefaultIPGateway,DHCPEnabled,MACAddress
  11. 3. Gets the foll. properties from Win32_IRQResource Class:
  12. IRQ Number
  13. 4. Gets the foll. properties from Win32_PortResource Class:
  14. StartingAddress, EndingAddress
  15. 5. Sets the "Change" property to "Snapshot" always
  16. Revision History:
  17. Ghim Sim Chua (gschua) 04/27/99
  18. - Created
  19. Kalyani Narlanka kalyanin
  20. - Added ServiceName, IPAddress, IPSubnet, DefaultIPGateway, DHCPEnabled,
  21. MACAddress 05/03/99
  22. - Added IRQNumber and PORT Resource 07/08 /99
  23. *******************************************************************************/
  24. #include "pchealth.h"
  25. #include "PCH_NetworkAdapter.h"
  26. ///////////////////////////////////////////////////////////////////////////////
  27. // Begin Tracing stuff
  28. //
  29. #ifdef THIS_FILE
  30. #undef THIS_FILE
  31. #endif
  32. static char __szTraceSourceFile[] = __FILE__;
  33. #define THIS_FILE __szTraceSourceFile
  34. #define TRACE_ID DCID_NETWORKADAPTER
  35. //
  36. // End Tracing stuff
  37. ///////////////////////////////////////////////////////////////////////////////
  38. //
  39. CPCH_NetworkAdapter MyPCH_NetworkAdapterSet (PROVIDER_NAME_PCH_NETWORKADAPTER, PCH_NAMESPACE) ;
  40. ///////////////////////////////////////////////////////////////////////////////
  41. //....Properties of PCHNetworkAdapter Class
  42. //
  43. const static WCHAR* pAdapterType = L"AdapterType" ;
  44. const static WCHAR* pTimeStamp = L"TimeStamp" ;
  45. const static WCHAR* pChange = L"Change" ;
  46. // const static WCHAR* pDefaultIPGateway = L"DefaultIPGateway" ;
  47. const static WCHAR* pDeviceID = L"DeviceID" ;
  48. const static WCHAR* pDHCPEnabled = L"DHCPEnabled" ;
  49. const static WCHAR* pIOPort = L"IOPort" ;
  50. // const static WCHAR* pIPAddress = L"IPAddress" ;
  51. // const static WCHAR* pIPSubnet = L"IPSubnet" ;
  52. const static WCHAR* pIRQNumber = L"IRQNumber" ;
  53. // const static WCHAR* pMACAddress = L"MACAddress" ;
  54. const static WCHAR* pProductName = L"ProductName" ;
  55. // const static WCHAR* pServiceName = L"ServiceName" ;
  56. //
  57. ///////////////////////////////////////////////////////////////////////////////
  58. //*****************************************************************************
  59. //
  60. // Function Name : CPCH_NetworkAdapter::EnumerateInstances
  61. //
  62. // Input Parameters : pMethodContext : Pointer to the MethodContext for
  63. // communication with WinMgmt.
  64. //
  65. // lFlags : Long that contains the flags described
  66. // in IWbemServices::CreateInstanceEnumAsync
  67. // Note that the following flags are handled
  68. // by (and filtered out by) WinMgmt:
  69. // WBEM_FLAG_DEEP
  70. // WBEM_FLAG_SHALLOW
  71. // WBEM_FLAG_RETURN_IMMEDIATELY
  72. // WBEM_FLAG_FORWARD_ONLY
  73. // WBEM_FLAG_BIDIRECTIONAL
  74. // Output Parameters : None
  75. //
  76. // Returns : WBEM_S_NO_ERROR
  77. //
  78. //
  79. // Synopsis : All instances of this class on the machine are returned.
  80. // If there are no instances returns WBEM_S_NO_ERROR.
  81. // It is not an error to have no instances.
  82. //
  83. //
  84. //*****************************************************************************
  85. HRESULT CPCH_NetworkAdapter::EnumerateInstances(MethodContext* pMethodContext,
  86. long lFlags)
  87. {
  88. TraceFunctEnter("CPCH_NetworkAdapter::EnumerateInstances");
  89. // Begin Declarations...................................................
  90. HRESULT hRes = WBEM_S_NO_ERROR;
  91. REFPTRCOLLECTION_POSITION posList;
  92. // Instances
  93. CComPtr<IEnumWbemClassObject> pNetworkAdapterEnumInst;
  94. CComPtr<IEnumWbemClassObject> pNetworkAdapterConfigurationEnumInst;
  95. CComPtr<IEnumWbemClassObject> pAllocatedResourceEnumInst;
  96. CComPtr<IEnumWbemClassObject> pPortResourceEnumInst;
  97. // PCH_NetworkAdapter Class instance
  98. CInstancePtr pPCHNetworkAdapterInstance;
  99. // Objects
  100. IWbemClassObjectPtr pNetworkAdapterObj;
  101. IWbemClassObjectPtr pNetworkAdapterConfigurationObj;
  102. IWbemClassObjectPtr pAllocatedResourceObj;
  103. IWbemClassObjectPtr pPortResourceObj;
  104. // Variants
  105. CComVariant varIndex;
  106. CComVariant varDeviceID;
  107. CComVariant varAntecedent;
  108. CComVariant varPortResource;
  109. CComVariant varName;
  110. CComVariant varIRQNumber;
  111. // Return Values;
  112. ULONG ulNetworkAdapterRetVal = 0;
  113. ULONG ulNetworkAdapterConfigurationRetVal = 0;
  114. ULONG ulAllocatedResourceRetVal = 0;
  115. ULONG ulPortResourceRetVal = 0;
  116. // Query Strings
  117. CComBSTR bstrNetworkAdapterQuery = L"Select AdapterType, DeviceID, ProductName, Index FROM win32_NetworkAdapter";
  118. CComBSTR bstrNetworkAdapterConfigurationQuery = L"Select ServiceName, IPAddress, IPSubnet, DefaultIPGateway, DHCPEnabled, MACAddress, Index FROM Win32_NetworkAdapterConfiguration WHERE Index=";
  119. CComBSTR bstrAllocatedResourceQuery = L"SELECT Antecedent, Dependent FROM Win32_AllocatedResource WHERE Dependent=\"Win32_NetworkAdapter.DeviceID=\\\"";
  120. CComBSTR bstrPortResourceQuery = L"Select StartingAddress, Name FROM Win32_PortResource WHERE ";
  121. // Other Query Strings
  122. CComBSTR bstrNetworkAdapterConfigurationQueryString;
  123. CComBSTR bstrAllocatedResourceQueryString;
  124. CComBSTR bstrPortResourceQueryString;
  125. // Other Strings
  126. CComBSTR bstrPropertyAntecedent = L"antecedent";
  127. CComBSTR bstrPropertyName = L"Name";
  128. CComBSTR bstrIndex = L"Index";
  129. CComBSTR bstrDeviceID = L"DeviceID";
  130. CComBSTR bstrResult;
  131. // SystemTime
  132. SYSTEMTIME stUTCTime;
  133. // Integers
  134. int i;
  135. int nIRQLen;
  136. int nIter;
  137. // Pattern Strings
  138. LPCSTR strIRQPattern = "Win32_IRQResource.IRQNumber=";
  139. LPCSTR strPortPattern = "Win32_PortResource.StartingAddress=";
  140. LPCSTR strPortPattern2 = "Win32_PortResource.";
  141. // Chars
  142. LPSTR strSource;
  143. LPSTR pDest;
  144. BOOL fValidInt;
  145. // End Declarations...................................................
  146. // Should take care of memory allocation failure for CComBSTRs
  147. // Get the date and time to update the TimeStamp Field
  148. GetSystemTime(&stUTCTime);
  149. //
  150. // Execute the query to get "AdapterType", "DeviceID", "Name" and "Index"
  151. // from Win32_NetworkAdapter Class.
  152. // "Index" is required as it is the common property between
  153. // Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration
  154. // pNetworkAdapterEnumInst contains a pointer to the list of instances returned.
  155. //
  156. hRes = ExecWQLQuery(&pNetworkAdapterEnumInst, bstrNetworkAdapterQuery);
  157. if (FAILED(hRes))
  158. {
  159. // Cannot get any properties.
  160. goto END;
  161. }
  162. // Query Succeeded!
  163. // Enumerate the instances from pNetworkAdapterEnumInst.
  164. // Get the next instance into pNetworkAdapterObj object.
  165. while(WBEM_S_NO_ERROR == pNetworkAdapterEnumInst->Next(WBEM_INFINITE, 1, &pNetworkAdapterObj, &ulNetworkAdapterRetVal))
  166. {
  167. // Create a new instance of PCH_NetworkAdapter Class based on the passed-in MethodContext
  168. CInstancePtr pPCHNetworkAdapterInstance(CreateNewInstance(pMethodContext), false);
  169. // Created a New Instance of PCH_NetworkAdapter Successfully.
  170. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  171. // TIME STAMP //
  172. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  173. hRes = pPCHNetworkAdapterInstance->SetDateTime(pTimeStamp, WBEMTime(stUTCTime));
  174. if (FAILED(hRes))
  175. {
  176. // Could not Set the Time Stamp
  177. // Continue anyway
  178. ErrorTrace(TRACE_ID, "SetDateTime on Timestamp Field failed.");
  179. }
  180. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  181. // CHANGE //
  182. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  183. hRes = pPCHNetworkAdapterInstance->SetCHString(pChange, L"Snapshot");
  184. if (FAILED(hRes))
  185. {
  186. // Could not Set the Change Property
  187. // Continue anyway
  188. ErrorTrace(TRACE_ID, "SetCHString on Change Field failed.");
  189. }
  190. // Copy the following properties from win32_NetworkAdapter class Instance
  191. // TO PCH_NetworkAdapter class Instance.
  192. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  193. // ADAPTERTYPE //
  194. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  195. CopyProperty(pNetworkAdapterObj, L"AdapterType", pPCHNetworkAdapterInstance, pAdapterType);
  196. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  197. // DEVICEID //
  198. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  199. CopyProperty(pNetworkAdapterObj, L"DeviceID", pPCHNetworkAdapterInstance, pDeviceID);
  200. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  201. // PRODUCTNAME //
  202. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  203. CopyProperty(pNetworkAdapterObj, L"ProductName", pPCHNetworkAdapterInstance, pProductName);
  204. /*
  205. Because of Bug : 100158 , regarding dropping all the privacy related properties,
  206. the foll. properties need to be dropped :
  207. ServiceName, IPAddress, IPSubnet, DefaultIPGateway, MACAddress
  208. */
  209. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  210. // INDEX //
  211. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  212. // Get the "Index" property from the current instance Object
  213. // Index is the common property between NetworkAdapter and NetworkAdapterConfiguration.
  214. hRes = pNetworkAdapterObj->Get(bstrIndex, 0, &varIndex, NULL, NULL);
  215. if (FAILED(hRes))
  216. {
  217. // Cannot get index.
  218. // Without Index Cannot get any properties from Win32_NetworkAdapterConfiguration Class
  219. ErrorTrace(TRACE_ID, "GetVariant on Index Field failed.");
  220. }
  221. else
  222. {
  223. // Got the index. Now we are ready to get the properties from Win32_NetworkAdapterConfiguration Class
  224. // With "index" as the key get the corresponding NetworkAdapterConfiguration instance
  225. // Make Sure Index is of Type VT_I4 i.e. long
  226. // Convert the Index to type VT_I4
  227. hRes = varIndex.ChangeType(VT_I4, NULL);
  228. if FAILED(hRes)
  229. {
  230. // Not of type VT_I4 So there is no way to get the Corresponding
  231. // NetworkAdapter Configuration instance
  232. }
  233. else
  234. {
  235. // index of expected Type. Get the corr. NetworkAdapterConfiguration instance
  236. // Append the "index" to the Query String
  237. bstrNetworkAdapterConfigurationQueryString = bstrNetworkAdapterConfigurationQuery;
  238. // Change varIndex to BSTR type so that it can be appended
  239. varIndex.ChangeType(VT_BSTR, NULL);
  240. bstrNetworkAdapterConfigurationQueryString.Append(V_BSTR(&varIndex));
  241. // Execute the query to get "ServiceName", "IPAddress", "IPSubnet",
  242. // "DefaultIPGateway", "DHCPEnabled", "MACAddress", "Index"
  243. // from Win32_NetworkAdapter Configuration Class.
  244. // pNetworkAdapterConfigurationEnumInst contains a pointer to the instance returned.
  245. hRes = ExecWQLQuery(&pNetworkAdapterConfigurationEnumInst,bstrNetworkAdapterConfigurationQueryString);
  246. if (FAILED(hRes))
  247. {
  248. // Query failed!! Cannot Copy Values.
  249. }
  250. else
  251. {
  252. // Query Succeeded. Get the Instance Object
  253. if (WBEM_S_NO_ERROR == pNetworkAdapterConfigurationEnumInst->Next(WBEM_INFINITE, 1, &pNetworkAdapterConfigurationObj, &ulNetworkAdapterConfigurationRetVal))
  254. {
  255. // Copy the following properties from win32_NetworkAdapterConfiguration
  256. // class Instance TO PCH_NetworkAdapter class Instance.
  257. /*
  258. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  259. // SERVICENAME //
  260. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  261. CopyProperty(pNetworkAdapterConfigurationObj, L"ServiceName", pPCHNetworkAdapterInstance, pServiceName);
  262. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  263. // IPADDRESS //
  264. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  265. CopyProperty(pNetworkAdapterConfigurationObj, L"IPAddress", pPCHNetworkAdapterInstance, pIPAddress);
  266. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  267. // IPSUBNET //
  268. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  269. CopyProperty(pNetworkAdapterConfigurationObj, L"IPSubnet", pPCHNetworkAdapterInstance, pIPSubnet);
  270. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  271. // DEFAULTIPGATEWAY //
  272. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  273. CopyProperty(pNetworkAdapterConfigurationObj, L"DefaultIPGateway", pPCHNetworkAdapterInstance, pDefaultIPGateway);
  274. */
  275. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  276. // DHCPENABLED //
  277. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  278. CopyProperty(pNetworkAdapterConfigurationObj, L"DHCPEnabled", pPCHNetworkAdapterInstance, pDHCPEnabled);
  279. /*
  280. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  281. // MACADDRESS //
  282. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  283. CopyProperty(pNetworkAdapterConfigurationObj, L"MACAddress", pPCHNetworkAdapterInstance, pMACAddress);
  284. */
  285. } //end of if pNetworkAdapterConfigurationEnumInst....
  286. } // end of else query succeeded
  287. } // end of else got the index
  288. } // end of else got the index
  289. // Get the resources from Win32_AllocatedResource
  290. // Update the Query String with the Device ID Property.
  291. bstrAllocatedResourceQueryString = bstrAllocatedResourceQuery;
  292. hRes = pNetworkAdapterObj->Get(bstrDeviceID, 0, &varDeviceID, NULL, NULL);
  293. if (FAILED(hRes))
  294. {
  295. // Current Instance object no longer required.
  296. // hRes = pNetworkAdapterObj->Release();
  297. if (FAILED(hRes))
  298. {
  299. // Unable to realease the Object
  300. ErrorTrace(TRACE_ID, "GetVariant on DeviceID Field while calculating IRQ and PORT Resource failed!");
  301. }
  302. // Cannot get DeviceID
  303. ErrorTrace(TRACE_ID, "GetVariant on DeviceID Field while calculating IRQ and PORT Resource failed!");
  304. } // end of cannot get the DeviceId
  305. else
  306. {
  307. // Current Instance object no longer required.
  308. // hRes = pNetworkAdapterObj->Release();
  309. if (FAILED(hRes))
  310. {
  311. // Unable to realease the Object
  312. ErrorTrace(TRACE_ID, "GetVariant on DeviceID Field while calculating IRQ and PORT Resource failed!");
  313. }
  314. // Got the DeviceID
  315. // Convert the DeviceID to type VT_BSTR
  316. hRes = varDeviceID.ChangeType(VT_BSTR, NULL);
  317. if FAILED(hRes)
  318. {
  319. // Cannot get the DeviceID value. So there is no way to get the Corresponding
  320. // IRQ and PORT Resources.
  321. } // end of FAILED hRes , Cannot get the DeviceID Value
  322. else
  323. {
  324. // Got the DeviceID value. Update the Query string with this value.
  325. _ASSERT(varDeviceID.vt == VT_BSTR);
  326. bstrAllocatedResourceQueryString.Append(V_BSTR(&varDeviceID));
  327. // Append "///" to the QueryString.
  328. bstrAllocatedResourceQueryString.Append("\\\"\"");
  329. // The Query string is formed, get the antecedent instances
  330. // Added the following line because you need to clear the CComPtr before you query the second time.
  331. pAllocatedResourceEnumInst = NULL;
  332. hRes = ExecWQLQuery(&pAllocatedResourceEnumInst, bstrAllocatedResourceQueryString);
  333. if (FAILED(hRes))
  334. {
  335. // Query failed!! Cannot get the Resources.
  336. // Continue anyway
  337. }
  338. else
  339. {
  340. // Get the "antecedent" value.
  341. // Query Succeeded. Get the Instance Object
  342. // Get all the instances of Win32_AllocatedResource applicable
  343. while(WBEM_S_NO_ERROR == pAllocatedResourceEnumInst->Next(WBEM_INFINITE, 1, &pAllocatedResourceObj, &ulAllocatedResourceRetVal))
  344. {
  345. hRes = pAllocatedResourceObj->Get(bstrPropertyAntecedent, 0, &varAntecedent, NULL, NULL);
  346. if (FAILED(hRes))
  347. {
  348. // Could not get the antecedent
  349. ErrorTrace(TRACE_ID, "GetVariant on Win32_AllocatedResource:Antecedent Field failed.");
  350. } //end of if FAILED(pAllocatedResourceObj->Get..antecedent
  351. else
  352. {
  353. // Got the antecedent
  354. // varAntecedent set to antecedent. Copy this to bstrResult
  355. varAntecedent.ChangeType(VT_BSTR, NULL);
  356. {
  357. USES_CONVERSION;
  358. strSource = OLE2A(varAntecedent.bstrVal);
  359. }
  360. // Check if it is IRQ Resource by comparing with the known pattern of IRQ Resource
  361. pDest = strstr(strSource,strIRQPattern);
  362. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  363. // IRQ Number //
  364. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  365. if(pDest != NULL)
  366. {
  367. // This is IRQ Resource instance
  368. // Can get the IRQ Number
  369. // Advance the pointer to the end of the pattern so the pointer is
  370. // positioned at IRQ Number
  371. pDest += lstrlen(strIRQPattern);
  372. // First verify that the given string is a valid integer.
  373. nIRQLen = lstrlen(pDest);
  374. fValidInt = TRUE;
  375. for(nIter = 0; nIter <nIRQLen; nIter++)
  376. {
  377. if (_istdigit(pDest[nIter]) == 0)
  378. {
  379. fValidInt = FALSE;
  380. break;
  381. }
  382. }
  383. if(fValidInt)
  384. {
  385. // Convert the IRQ Number that you get as string to a long
  386. varIRQNumber = atol(pDest);
  387. // Set the IRQ Number as a variant
  388. hRes = pPCHNetworkAdapterInstance->SetVariant(pIRQNumber, varIRQNumber);
  389. if (!hRes)
  390. {
  391. ErrorTrace(TRACE_ID, "SetVariant on win32_AllocatedResource.IRQ Number Failed!");
  392. // Proceed Anyway
  393. }
  394. }
  395. } // end of if pDest != NULL
  396. else
  397. {
  398. // This is not IRQ Resource
  399. } // end of else pDest != NULL
  400. // Check if it is PORT Resource
  401. pDest = strstr(strSource,strPortPattern);
  402. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  403. // PORTRESOURCE //
  404. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  405. if(pDest != NULL)
  406. {
  407. // This is PORT Resource instance
  408. // Can get the PORT Resource Starting Address
  409. // Advance the pointer to the end of the pattern so the pointer is
  410. // positioned at "Win32_PortResource...." Portion
  411. pDest += lstrlen(strPortPattern2);
  412. // Formulate the Query String
  413. bstrPortResourceQueryString = bstrPortResourceQuery;
  414. bstrPortResourceQueryString.Append(pDest);
  415. // At this point the WQL Query can be used to get the win32_portResource Instance.
  416. hRes = ExecWQLQuery(&pPortResourceEnumInst, bstrPortResourceQueryString);
  417. if (FAILED(hRes))
  418. {
  419. // Query failed!! Cannot get the PORT Resources.
  420. // Continue anyway!
  421. }
  422. else
  423. {
  424. // Query Succeeded. Get the Instance Object
  425. if(WBEM_S_NO_ERROR == pPortResourceEnumInst->Next(WBEM_INFINITE, 1, &pPortResourceObj, &ulPortResourceRetVal))
  426. {
  427. // Get the Name
  428. hRes = pPortResourceObj->Get(bstrPropertyName, 0, &varName, NULL, NULL);
  429. if (FAILED(hRes))
  430. {
  431. // Could not get the Name
  432. ErrorTrace(TRACE_ID, "GetVariant on Win32_PortResource: Field failed.");
  433. } //end of if FAILED(pPortResourceObj->Get..Name
  434. else
  435. {
  436. // Got the Name
  437. // This is the PORT Address. Set the Value
  438. if (!pPCHNetworkAdapterInstance->SetVariant(pIOPort, varName))
  439. {
  440. ErrorTrace(TRACE_ID, "SetVariant on win32_AllocatedResource.PortAddress Failed!");
  441. }
  442. else
  443. {
  444. // Port Address is set.
  445. }
  446. } // end of else FAILED(pPortResourceObj->Get..Name
  447. // Got the Name. Nothing more to do.
  448. } //end of if WBEM_S_NO_ERROR
  449. else
  450. {
  451. // Cannot get the Instance Object
  452. // Cannot get the PORT Adresses.
  453. } //end of else WBEM_S_NO_ERROR
  454. } //end of else FAILED(hRes)
  455. } //end of if pDest!= NULL
  456. else
  457. {
  458. // Not a PORT Resource Instance
  459. } //end of else pDest!= NULL
  460. } ////end of else FAILED(pAllocatedResourceObj->Get..antecedent
  461. }// end of while pAllocatedResourceEnumInst....
  462. } // end of else FAILED(hRes) got the Antecedent Value
  463. } // end of else FAILED(hRes) , got the DeviceID Value
  464. } // end of else got the DeviceID
  465. // Get the resources from Win32_AllocatedResource END
  466. // All the properties in pPCHNetworkAdapterInstance are set
  467. hRes = pPCHNetworkAdapterInstance->Commit();
  468. if (FAILED(hRes))
  469. {
  470. // Cannot commit the Instance
  471. ErrorTrace(TRACE_ID, "Commit on Instance failed.");
  472. } // end of if FAILED(hRes)
  473. } //end of while pEnumInst....
  474. END :
  475. TraceFunctLeave();
  476. return hRes ;
  477. }