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.

83 lines
2.1 KiB

  1. // Copyright (c) Microsoft. All rights reserved.
  2. //
  3. // This is unpublished source code of Microsoft.
  4. // The copyright notice above does not evidence any
  5. // actual or intended publication of such source code.
  6. // OneLiner : Implementation of MNicInfo
  7. // DevUnit : wlbstest
  8. // Author : Murtaza Hakim
  9. // include files
  10. #include "MNicInfo.h"
  11. #include "MWmiParameter.h"
  12. #include "MWmiInstance.h"
  13. #include "MWmiObject.h"
  14. #include "Mtrace.h"
  15. MNicInfo::MNicInfo_Error
  16. MNicInfo::getNicInfo( _bstr_t machineIP,
  17. vector<MNicInfo::Info>* nicList )
  18. {
  19. MWmiObject machine( machineIP,
  20. L"root\\cimv2",
  21. L"Administrator",
  22. L"" );
  23. return getNicInfo_private( &machine, nicList );
  24. }
  25. MNicInfo::MNicInfo_Error
  26. MNicInfo::getNicInfo( vector<MNicInfo::Info>* nicList )
  27. {
  28. MWmiObject machine( L"root\\cimv2" );
  29. return getNicInfo_private( &machine, nicList );
  30. }
  31. MNicInfo::MNicInfo_Error
  32. MNicInfo::getNicInfo_private( MWmiObject* p_machine,
  33. vector<MNicInfo::Info>* nicList )
  34. {
  35. vector< MWmiInstance > instanceStore;
  36. MWmiObject::MWmiObject_Error errO;
  37. errO = p_machine->getInstances( L"Win32_NetworkAdapterConfiguration",
  38. &instanceStore );
  39. if( errO != MWmiObject::MWmiObject_SUCCESS )
  40. {
  41. TRACE( MTrace::SEVERE_ERROR, "MIPAddressAdmin::checkStatus failure\n");
  42. return COM_FAILURE;
  43. }
  44. // set parameters to get.
  45. vector<MWmiParameter* > parameterStore;
  46. MWmiInstance::MWmiInstance_Error errI;
  47. MWmiParameter Caption(L"Caption");
  48. parameterStore.push_back( &Caption );
  49. MWmiParameter SettingID(L"SettingID");
  50. parameterStore.push_back( &SettingID );
  51. Info info;
  52. for( int i = 0; i < instanceStore.size(); ++i )
  53. {
  54. errI = instanceStore[i].getParameters( parameterStore );
  55. info.nicFullName = _bstr_t( (wchar_t *)_bstr_t( Caption.getValue()) + 11 );
  56. info.guid = SettingID.getValue();
  57. nicList->push_back( info );
  58. }
  59. return MNicInfo_SUCCESS;
  60. }